8

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...

assylias
  • 416
  • 1
  • 3
  • 14
ElektroStudios
  • 1,590
  • 7
  • 22
  • 49

5 Answers5

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!)

Karan
  • 55,947
  • 20
  • 119
  • 191
6

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

user1301428
  • 3,325
  • 11
  • 37
  • 55
  • thankyou for comment, i've tried but the result is the same: "file already exist" – ElektroStudios Jan 18 '13 at 08: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 '13 at 11:14
  • @Sam that's what I remembered too, but then I thought that maybe using a specific update option could help – user1301428 Jan 18 '13 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. – ElektroStudios Jan 18 '13 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 '13 at 23:09
3

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

Petr Abdulin
  • 1,746
  • 2
  • 16
  • 25
1

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).
Sam
  • 1,410
  • 1
  • 20
  • 33
  • Thanks, I know by deleting first the files is a solution... but I'm searching for a solution using the parameters of 7zip. – ElektroStudios Jan 18 '13 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 '13 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.

Sam
  • 1,410
  • 1
  • 20
  • 33