I like to use mdx file for archiving project, its compress max file too, later u can use daemon tool to mount it.
Obviously, I need to say a few key points here:
#1 This compression solution need to process big project folder (500MB an above).
So compression level has to be the greatest which will produce small archive size.
Processing time is not so important here.
The user should see this process in order to know when is compression done.
To achive this we can use DOSCommand (or ShellLunch for *.bat files) fn instead of HiddenDOSCommand.
#2 The reason why I chose WinRAR(commercial) and 7zip(freeware) archiver is because
there are many users already have some of these already installed.
I did not choose WinZip because previously mentioned archivers can also create *.zip files.
@k4noe mentioned .mdx (Extended Media Descriptor File) which is disk image files.
If I decide to use any CD / DVD / BD image file processing tool I will probably pick
UltraISO (can create ISO Zipped Format [.isz]) or PowerISO (can create Direct-Access-Archive [*.daa]). BTW *.daa files have very small size.
7z has a very good compression rate but keep in mind it’s much slower than other solutions.
But enough of talking , it’s about time to see some good solution.
Let’s start with WinRAR and then 7zip.
Fajar started with solid approach but without good explanation.
Here you can see all RAR commands and switches, and here all 7ZIP commands and switches.
This fn is based on Fajar solution
fn compressToRAR folder: rarFile: compressLevel: password: rarDir:@"C:\Program Files\WinRAR\" = if doesDirectoryExist folder do
(
rarFile = if pathConfig.isPathRootedAtBackslash rarFile or pathConfig.isPathRootedAtDriveLetter rarFile then rarFile
else pathConfig.appendPath folder rarFile
local doWR = "start /d " + "\""+rarDir+"\""+" rar.exe "
local switches = "a -ac -ai -ep1 -kb -ibck -os -rr3p -s -ds -ed -r -y -m"+ compressLevel as string
if password != unsupplied do switches += (" -p" + password)
DOSCommand (doWR + switches + " "+ "\"" + rarFile + "\"" + " " + "\"" + folder + "\"")
)
compressToRAR folder:@"c: emp est" rarFile:"project.rar" compressLevel:5 password:"123456789"
I removed switch that removes all files after compression.
[i][b]Arguments[/b][/i]:
[i][b]folder[/b]:[/i] --> folder that we need to compress ei. project folder
[i][b]rarFile:[/b][/i] --> if we use only filename with extension ("project.rar") then newley archive will
be placed in the source (project) folder. To change destination of this file use
fullFileName (example:@"c:\somefolder\somefilename.rar").
[i][b]compressLevel:[/b][/i] --> can be range of integers from 0 to 5 which means:
0 "Store", 1 "Fastest", 2 "Fast", 3 " Normal", 4 "Good" and 5 "Best"
[i][b]password:[/b][/i] --> set password (or not) as string.
NOTE: PASSWORD NOT WORKS I DON'T KNOW WHY?
[i][b]rarDir:[/b][/i] --> installation WinRAR folder. Default : @"C:\Program Files\WinRAR\"
edit: Is It order of switches important for password to work or not?
You can find users that not use WinRAR or 7zip. I personaly use 7zip only, but on all of the PC that I have to “fix” i install IZArc(because it supports more than 40 archive formats). So, I have a suggestion – use portable 7zip. This way you will not be committed to the archiver that the user uses.
Thanks for the very useful info. For now we have only solution for winrar which is not free.
IZArc sounds good for sure. If anyone can write similar fn from above for IZArc or 7Zip archiver that will be awesome. String for DOSCommand fn is not easy to guess
Kostadin do you how to do this?
personally i will not use any max tool that instals anything else on my machine except the tool itself.
That’s why I decided to have two or three choices for compression. But I also will include max default compression method.
Ok. This is the final solution for WinRAR compression.
> fixed password issue by changing “-p” switch to “-hp”
Switch -HP[pwd] – encrypt both file data and headers
[i]
This switch is similar to -p[p], but switch -p encrypts only file data and leaves other
information like file names visible. This switch encrypts all sensitive archive areas
including file data, file names, sizes, attributes, comments and other blocks, so it
provides a higher security level. Without a password it is impossible to view even the
list of files in archive encrypted with -hp.
[/i]
This is the list of all switches that are used in below fn
-ac … clear Archive attribute
-ai … ignore file attributes
-ep1 … exclude base folder from names
-kb … keep broken extracted files
-ibck … run WinRAR in background
-os … save NTFS streams
-rr3p … add data recovery record
-s … create solid archive
-ds … do not sort archiving files
-ed … do not add empty folders
-r … recurse subfolders
-y … assume Yes on all queries
-m5 … set compression method
-hp … encrypt both file data and headers
fn compressToRAR folder: rarFile: compressLevel: password: rarDir:@"C:\Program Files\WinRAR\" = if doesDirectoryExist folder do
(
rarFile = if pathConfig.isPathRootedAtBackslash rarFile or pathConfig.isPathRootedAtDriveLetter rarFile then rarFile
else pathConfig.appendPath folder rarFile
local doWR = "start /d " + "\""+rarDir+"\""+" rar.exe "
local switches = "a -ac -ai -ep1 -kb -ibck -os -rr3p -s -ds -ed -r -y -m"+ compressLevel as string
if password != unsupplied do switches += (" -hp" + password)
DOSCommand (doWR + switches + " "+ "\"" + rarFile + "\"" + " " + "\"" + folder + "\"")
)
compressToRAR folder:@"c: emp est" rarFile:"project.rar" compressLevel:5 password:"123456789"
Next stop … 7zip compression method