How to overwrite existing zip file instead of updating it in Info-Zip?
Use the -FS option to "file sync"
zip -FSr foo.zip foo
This will add any new files in the folder to the zip, and delete any files from the zip that aren't in the folder.
An alternative to using the -FS
option (or deleting the old ZIP file), is to overwrite the existing ZIP file by having zip
write to stdout and redirecting it to the designated file:
zip -r - foo >foo.zip
-r : Add directory and its contents
- : Instead of writing ZIP to a file, write to stdout
foo : The directory to be zipped
>foo.zip : Redirect stdout to file foo.zip
If foo.zip
exists, it will be overwritten by shell redirection, meaning you'll get a fresh new ZIP file 100% of the time, every time.