9

I'm trying this:

7za.exe a "C:\Disc.7z" "C:\test" -v20000000b -m0=BCJ -bd

But if I already have created the file C:\Disc.7z then 7zip doesn't compress anything and sends me this output:

System error:
File already exist.

I've tried with the switch -y, but 7zip does not do anything...

How can I overwrite the file?


UPDATE

I've tried the switch -aoa but it does not work either...

3
  • Try to do it from an elevated (Run as administrator) cmd
    – Ofiris
    Jan 18, 2013 at 10:54
  • @Ofiris, that doesn't fix the problem.
    – Sam
    Jan 18, 2013 at 10:58
  • Is it acceptable for 7-Zip to update the existing archives rather than overwriting them?
    – Sam
    Jan 18, 2013 at 23:08

5 Answers 5

11

Your problem is that you're using -v to create a multi-volume archive. People have been requesting the author for the last 5 years to allow the program to modify multi-volume archives, but he has no plans to implement the feature any time soon. (It's open source, wish some enterprising programmer would do it already!)

6

Try using 7za.exe u instead of 7za.exe a. The first one is specifically used to update an archive that already exists.

5
  • thankyou for comment, i've tried but the result is the same: "file already exist" Jan 18, 2013 at 8:40
  • 7-Zip normally updates archives if they already exist. The reason it doesn't work in this case is the -v switch is being used.
    – Sam
    Jan 18, 2013 at 11:14
  • @Sam that's what I remembered too, but then I thought that maybe using a specific update option could help Jan 18, 2013 at 12:18
  • @sam, I've tryed it before post with the -volume switch and without it (and without any other switch), the result is the same (tested with 7zip 7.20 and 7.22 beta), sorry for my english. Jan 18, 2013 at 18:16
  • @ElektroHacker, that's interesting. When I test it, if I remove the -v switch, everything works correctly; 7-Zip creates the archive if it doesn't exist, and it updates it if it already exists. Don't worry about your English; it's clear.
    – Sam
    Jan 18, 2013 at 23:09
3

Currently there is no way to have this functionality with command line switches. Overwriting is supported only during archive extraction.

2

Work-Around

To work around this problem, you could delete the archive files if they exist before you create them again. Here's one way to do this:

CMD /C FOR %i IN (C:\Disc.7z.???) DO DEL %i && 7za.exe a "C:\Disc.7z" "C:\test" -v20000000b -m0=BCJ -bd

Explanation

  • The CMD /C ensures that the 7za command is only executed once rather than for each file.
  • The FOR iterates through each destination archive file and deletes it. Note that the expression only covers volumes with three-digit suffixes. If you expect more (which I'm not sure is possible), you could replace the ??? with *.
  • The && runs the second command after the first (if the first is successful).
2
  • Thanks, I know by deleting first the files is a solution... but I'm searching for a solution using the parameters of 7zip. Jan 18, 2013 at 10:55
  • It looks like this is a bug in 7-Zip, so I suspect that a work-around is your only option outside of changing the source or waiting for a bug fix.
    – Sam
    Jan 18, 2013 at 11:00
1

I've noticed that this problem doesn't occur for me if I remove the -v switch. It appears that 7-Zip doesn't support updating archive volumes.

You must log in to answer this question.

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