Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

migrated from stackoverflow.com Jan 18 '13 at 21:11

This question came from our site for professional and enthusiast programmers.

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

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

share|improve this answer

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

share|improve this answer

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

share|improve this answer
    
thankyou for comment, i've tried but the result is the same: "file already exist" – ElektroStudios Jan 18 '13 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 '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

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).
share|improve this answer
    
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

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.

share|improve this answer

You must log in to answer this question.

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