4

On the command line, 7-Zip has the command 'a' to "Add files to archive". But I want to synchronise the files instead. This is one of the main options in the GUI, but the CLI has disregarded it for some reason.

How can I do this? An example would be appreciated.

6

Using some info I found online, I figured out that -uq0 is the switch you probably want. Here's an example of an update script I just tested out based on this:

"C:\Program Files\7-Zip\7z.exe" u "C:\Users\dane\Documents\Docz.7z" -uq0 "C:\Users\dane\Documents\*" -r -x!*.7z -ssw -ms=off

I tested this out and it removed a file from the archive after I deleted the file.

  • Ah that did the trick! I previously saw that page, but next to "Synchronize", it says set p to 1, q to 0, r to 2, x to 1 etc. etc. (i.e. "-u-p1q0r2x1y2z1w2" - which I tried and it didn't work). I'm not sure how you interpreted the seemingly cryptic description so well. – Dan W Jan 4 '13 at 21:09
  • 1
    Actually, you had it right, except you inserted an extra dash in "-u-p1q0r2x1y2z1w2". If you had just used "-up1q0r2x1y2z1w2" instead, you would've been good, I believe. That dash in "-u-" apparently disables updates to the base archive, which would totally negate my example line if included. My example of "u -uq0" is identical to "u -up1q0r2x1y2z1w2", because only the "q0" is different from what "u" usually does. – Dane Jan 4 '13 at 21:16
  • Great that explains it all, and makes perfect sense. Thanks a lot! – Dan W Jan 4 '13 at 21:32
3

Use the 'u' operator (update)

Slightly edited snippit from a backup job I run:

7z.exe u Documents.7z ".\Documents\*" -r -x!*.7z -x!*.pst -t7z -ssw -mx=3 -m3=LZMA2 -mmt=2 
  • Simply using 'u' doesn't sync, as files which are in the archive which aren't in the original files/folder anymore aren't deleted. – Dan W Jan 4 '13 at 18:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.