Using the zip command zip -qrj dir1/archive.zip dir2/*.jpg.

After removing a file from dir2 I want to synchronize the archive using dir2 as reference. I.e. remove the file from the zip archive as well. It seems it only adds or updates files but doesn't remove them.

Have tried zip -qrju dir1/archive.zip dir2/*.jpg but it doesn't remove the file.

  • I miss-read your question rather big in my answer :P No use here I guess, so I delete it.
    – ibuprofen
    Commented Aug 24, 2021 at 21:18

1 Answer 1


The -FS option:

-FS --filesync Synchronize the contents of an archive with the files on the OS. Normally when an archive is updated, new files are added and changed files are updated but files that no longer exist on the OS are not deleted from the archive. This option enables a new mode that checks entries in the archive against the file system. If the file time and file size of the entry matches that of the OS file, the entry is copied from the old archive instead of being read from the file system and compressed. If the OS file has changed, the entry is read and compressed as usual. If the entry in the archive does not match a file on the OS, the entry is deleted. Enabling this option should create archives that are the same as new archives, but since existing entries are copied instead of compressed, updating an existing archive with -FS can be much faster than cre‐ ating a new archive. Also consider using -u for updating an archive.

zip -qrj -FS dir1/archive.zip dir2/*.jpg

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .