Jump to content
Sign in to follow this  
syko

making file compressor

Recommended Posts

syko

I am making compressor, this is to make files smaller.

right now I use static method (you shall see in my code)

I was wondering, is there dynamic method, it find lots of groups of characters that repeats and replaces them with a list of replacement characters (predefined in array at top of script)

here my code: (it take 602kb file to 562kb)

#include <string.au3>
$contents = FileRead("ResoucesViewer.exe")
$contents = Binary($contents)
$contents = StringRegExpReplace($contents, "0000", "§")
$contents = StringRegExpReplace($contents, "00", "¤")
$contents = StringRegExpReplace($contents, "§§", "®")
$contents = StringRegExpReplace($contents, "¤¤", "¯")
$contents = StringRegExpReplace($contents, "1111", "²")
$contents = StringRegExpReplace($contents, "11", "³")
$contents = StringRegExpReplace($contents, "2222", "")
$contents = StringRegExpReplace($contents, "22", "")
$contents = StringRegExpReplace($contents, "3333", "")
$contents = StringRegExpReplace($contents, "33", "")
$contents = StringRegExpReplace($contents, "4444", "¨")
$contents = StringRegExpReplace($contents, "44", "©")
$contents = StringRegExpReplace($contents, "5555", "ª")
$contents = StringRegExpReplace($contents, "55", "«")
$contents = StringRegExpReplace($contents, "6666", "¬")
$contents = StringRegExpReplace($contents, "66", "­")
$contents = StringRegExpReplace($contents, "7777", "+")
$contents = StringRegExpReplace($contents, "77", "±")
$contents = StringRegExpReplace($contents, "FFFF", "´")
$contents = StringRegExpReplace($contents, "FF", "µ")
$contents = StringRegExpReplace($contents, "AA", "·")
$contents = StringRegExpReplace($contents, "AAAA", "¸")
$contents = StringRegExpReplace($contents, "BB", "¹")
$contents = StringRegExpReplace($contents, "BBBB", "º")
$contents = StringRegExpReplace($contents, "CC", "»")
$contents = StringRegExpReplace($contents, "CCCC", "¼")
$contents = StringRegExpReplace($contents, "DD", "½")
$contents = StringRegExpReplace($contents, "DDDD", "¾")
$contents = StringRegExpReplace($contents, "EE", "¿")
$contents = StringRegExpReplace($contents, "EEEE", "À")
$contents = StringRegExpReplace($contents, "FF", "Á")
$contents = StringRegExpReplace($contents, "FFFF", "Â")
$contents = StringRegExpReplace($contents, "GG", "Ã")
$contents = StringRegExpReplace($contents, "GGGG", "Ä")
$contents = StringRegExpReplace($contents, "HH", "Å")
$contents = StringRegExpReplace($contents, "HHHH", "Æ")
$contents = StringRegExpReplace($contents, "II", "Ç")
$contents = StringRegExpReplace($contents, "IIII", "È")
$contents = StringRegExpReplace($contents, "JJ", "É")
$contents = StringRegExpReplace($contents, "JJJJ", "Ê")
$contents = StringRegExpReplace($contents, "KK", "Ë")
$contents = StringRegExpReplace($contents, "KKKK", "Ì")
$contents = StringRegExpReplace($contents, "LL", "Í")
$contents = StringRegExpReplace($contents, "LLLL", "Î")
$contents = StringRegExpReplace($contents, "MM", "Ï")
$contents = StringRegExpReplace($contents, "MMMM", "Ð")
$contents = StringRegExpReplace($contents, "NN", "Ñ")
$contents = StringRegExpReplace($contents, "NNNN", "Ò")
$contents = StringRegExpReplace($contents, "OO", "Ó")
$contents = StringRegExpReplace($contents, "OOOO", "Ô")
$contents = StringRegExpReplace($contents, "PP", "Õ")
$contents = StringRegExpReplace($contents, "PPPP", "Ö")
$contents = StringRegExpReplace($contents, "QQ", "×")
$contents = StringRegExpReplace($contents, "QQQQ", "Ø")
$contents = StringRegExpReplace($contents, "RR", "Ù")
$contents = StringRegExpReplace($contents, "RRRR", "Ú")
$contents = StringRegExpReplace($contents, "SS", "Û")
$contents = StringRegExpReplace($contents, "SSSS", "Ü")
$contents = StringRegExpReplace($contents, "TT", "Ý")
$contents = StringRegExpReplace($contents, "TTTT", "Þ")
$contents = StringRegExpReplace($contents, "UU", "ß")
$contents = StringRegExpReplace($contents, "UUUU", "à")
$contents = StringRegExpReplace($contents, "VV", "á")
$contents = StringRegExpReplace($contents, "VVVV", "â")
$contents = StringRegExpReplace($contents, "WW", "ã")
$contents = StringRegExpReplace($contents, "WWWW", "ä")
$contents = StringRegExpReplace($contents, "XX", "å")
$contents = StringRegExpReplace($contents, "XXXX", "æ")
$contents = StringRegExpReplace($contents, "YY", "ç")
$contents = StringRegExpReplace($contents, "YYYY", "è")
$contents = StringRegExpReplace($contents, "ZZ", "é")
$contents = StringRegExpReplace($contents, "ZZZZ", "ê")
$contents = StringRegExpReplace($contents, "B0", "*")
$contents = StringRegExpReplace($contents, "0F", "#")
FileWrite("6.txt",$contents&@CRLF)
Edited by syko

Share this post


Link to post
Share on other sites
trancexx

I am making compressor, this is to make files smaller.

right now I use static method (you shall see in my code)

I was wondering, is there dynamic method, it find lots of groups of characters that repeats and replaces them with a list of replacement characters (predefined in array at top of script)

here my code: (it take 602kb file to 562kb)

#include <string.au3>
$contents = FileRead("ResoucesViewer.exe")
$contents = Binary($contents)
$contents = StringRegExpReplace($contents, "0000", "§")
$contents = StringRegExpReplace($contents, "00", "¤")
$contents = StringRegExpReplace($contents, "§§", "®")
$contents = StringRegExpReplace($contents, "¤¤", "¯")
$contents = StringRegExpReplace($contents, "1111", "²")
$contents = StringRegExpReplace($contents, "11", "³")
$contents = StringRegExpReplace($contents, "2222", "")
$contents = StringRegExpReplace($contents, "22", "")
$contents = StringRegExpReplace($contents, "3333", "")
$contents = StringRegExpReplace($contents, "33", "")
$contents = StringRegExpReplace($contents, "4444", "¨")
$contents = StringRegExpReplace($contents, "44", "©")
$contents = StringRegExpReplace($contents, "5555", "ª")
$contents = StringRegExpReplace($contents, "55", "«")
$contents = StringRegExpReplace($contents, "6666", "¬")
$contents = StringRegExpReplace($contents, "66", "­")
$contents = StringRegExpReplace($contents, "7777", "+")
$contents = StringRegExpReplace($contents, "77", "±")
$contents = StringRegExpReplace($contents, "FFFF", "´")
$contents = StringRegExpReplace($contents, "FF", "µ")
$contents = StringRegExpReplace($contents, "AA", "·")
$contents = StringRegExpReplace($contents, "AAAA", "¸")
$contents = StringRegExpReplace($contents, "BB", "¹")
$contents = StringRegExpReplace($contents, "BBBB", "º")
$contents = StringRegExpReplace($contents, "CC", "»")
$contents = StringRegExpReplace($contents, "CCCC", "¼")
$contents = StringRegExpReplace($contents, "DD", "½")
$contents = StringRegExpReplace($contents, "DDDD", "¾")
$contents = StringRegExpReplace($contents, "EE", "¿")
$contents = StringRegExpReplace($contents, "EEEE", "À")
$contents = StringRegExpReplace($contents, "FF", "Á")
$contents = StringRegExpReplace($contents, "FFFF", "Â")
$contents = StringRegExpReplace($contents, "GG", "Ã")
$contents = StringRegExpReplace($contents, "GGGG", "Ä")
$contents = StringRegExpReplace($contents, "HH", "Å")
$contents = StringRegExpReplace($contents, "HHHH", "Æ")
$contents = StringRegExpReplace($contents, "II", "Ç")
$contents = StringRegExpReplace($contents, "IIII", "È")
$contents = StringRegExpReplace($contents, "JJ", "É")
$contents = StringRegExpReplace($contents, "JJJJ", "Ê")
$contents = StringRegExpReplace($contents, "KK", "Ë")
$contents = StringRegExpReplace($contents, "KKKK", "Ì")
$contents = StringRegExpReplace($contents, "LL", "Í")
$contents = StringRegExpReplace($contents, "LLLL", "Î")
$contents = StringRegExpReplace($contents, "MM", "Ï")
$contents = StringRegExpReplace($contents, "MMMM", "Ð")
$contents = StringRegExpReplace($contents, "NN", "Ñ")
$contents = StringRegExpReplace($contents, "NNNN", "Ò")
$contents = StringRegExpReplace($contents, "OO", "Ó")
$contents = StringRegExpReplace($contents, "OOOO", "Ô")
$contents = StringRegExpReplace($contents, "PP", "Õ")
$contents = StringRegExpReplace($contents, "PPPP", "Ö")
$contents = StringRegExpReplace($contents, "QQ", "×")
$contents = StringRegExpReplace($contents, "QQQQ", "Ø")
$contents = StringRegExpReplace($contents, "RR", "Ù")
$contents = StringRegExpReplace($contents, "RRRR", "Ú")
$contents = StringRegExpReplace($contents, "SS", "Û")
$contents = StringRegExpReplace($contents, "SSSS", "Ü")
$contents = StringRegExpReplace($contents, "TT", "Ý")
$contents = StringRegExpReplace($contents, "TTTT", "Þ")
$contents = StringRegExpReplace($contents, "UU", "ß")
$contents = StringRegExpReplace($contents, "UUUU", "à")
$contents = StringRegExpReplace($contents, "VV", "á")
$contents = StringRegExpReplace($contents, "VVVV", "â")
$contents = StringRegExpReplace($contents, "WW", "ã")
$contents = StringRegExpReplace($contents, "WWWW", "ä")
$contents = StringRegExpReplace($contents, "XX", "å")
$contents = StringRegExpReplace($contents, "XXXX", "æ")
$contents = StringRegExpReplace($contents, "YY", "ç")
$contents = StringRegExpReplace($contents, "YYYY", "è")
$contents = StringRegExpReplace($contents, "ZZ", "é")
$contents = StringRegExpReplace($contents, "ZZZZ", "ê")
$contents = StringRegExpReplace($contents, "B0", "*")
$contents = StringRegExpReplace($contents, "0F", "#")
FileWrite("6.txt",$contents&@CRLF)
There are some functions that windows natively have for purposes of compressing data and are available to be used with AutoIt.

For compressing you can use RtlCompressBuffer and decompressing RtlDecompressBuffer function (ntdll.dll).

There are examples for both of them in example scripts forum, so just use search engine.

Btw, get familiar with StringReplace() function and maybe FileOpen() too.

Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×