My Technical Notes

Tuesday, 2 August 2016

Zip a Code Directory using 7zip command line

This solution using the command line application of 7z.

If you have a folder called `myproject`, then we can create a zip file containing this folder using a bat file in the same folder at `myproject`:


IF EXIST myproject.zip del myproject.zip
"c:\Program Files\7-Zip\7z.exe" a myproject.zip .\myproject\ -xr!.git -xr!.gitignore
pause

If you wish the contents of `myproject` to be the contents of the zip, then you use `.\myproject\*` instead of `.\myproject\`.

No comments: