Today I've started to play with 7zip. I had to make archive from one of our CakePHP project, but I had following requirements.
.svn folder(s) should not be part of my archive
/app/tmp/cache/images/ should not contain any file
/app/tmp/cache/thumbs/ should not contain any file
/app/tmp/cache/models/ should not contain any file
/app/tmp/cache/persistent/ should not contain any file
I found out that 7zip is very powerful tool, but you must know how to use it exactly. But because I'm a PHP developer, I used my favorite method - try and failure.
c:\>7z.exe a -mx9 -tzip {archive_name}.zip -ir!{folder_name}\* -xr!.svn -xr!*.tmp -xr!cake_model_* -xr!cake_core_*
| archive_name | name of result file with archive |
| folder_name | name of folder which should be archived |
I've met 4 of my 5 requirements with command mentioned above. I have to find solution for the last one /app/tmp/cache/thumbs/ should not contain any file. This folder holds all thumbs files created by phpThumb and they do not have any extension.
So I need to find formula what to specify -xr! parameter.
Name of all files inside this folder is md5 hash - so it means 32 random characters.
-x!{folder_name}\app\tmp\cache\thumbs\*
I spent maybe one hour with this problem. Archive file did not contain folders which were empty or contained only empty files. But finally I found the solution. If you have same problem, do not use *.* but only *
| -ir!{folder_name}\*.* | will not include empty folders |
| -ir!{folder_name}\* | will include empty folders |
This blogs post was created on 2012-01-20 at 14:39 and last modified on 2012-01-20 at 18:07 by
Tomas Pavlatka.
It is tagged with 7zip, archive, command line, empty folders, problem solution.