18

I am trying to write a batch script to extract files out of an existing ZIP file, into another folder on my desktop and to have the system not prompt me as to whether I want to overwrite the existing files or not. The script works with just -o, but once I add -aoa, I get an error:

"C:\Program Files\7-zip\7z.exe" e file1.zip "-aoaC:\Documents and Settings\All Users\Desktop\all_backup_files"
Larry
  • 203
  • 1
  • 2
  • 6

2 Answers2

23

The 7-Zip command line options you will need are x, -o and -y:

"C:\Program Files\7-zip\7z.exe" x file1.zip -o"C:\Documents and Settings\All Users\Desktop\all_backup_files" -y

Note there mustn't be a gap between -o and the folder name.

If you type 7z --help you will get a list of valid parameters.

SeanC
  • 3,704
  • Thanks very much for this Sean. For me it was where to put the switch. I fixed the batch programs and they all work great now. – Larry Oct 03 '12 at 19:24
4
"C:\Program Files\7-zip\7z.exe" e file1.zip " -aoa -o"C:\Documents and Settings\All Users\Desktop\all_backup_files"

Note there mustn't be a gap between -o and the folder name.

this will solve the problem refer https://sevenzip.osdn.jp/chm/cmdline/switches/overwrite.htm

  • 1
    Welcome to Super User. On this Q&A site we value answers that remain useful if/when linked material becomes inaccessable. Please [edit] your answer so that it includes the essential elements from your linked source. – I say Reinstate Monica Apr 09 '18 at 13:43
  • 1
    On top of which, this doesn't seem to work. Not sure if it's a version issue, but pasting this exact command into my CLI results in the error "Too long switch". Despite when I check --help, the -aoa switch is listed.

    The only command that worked for me is SeanC's above.

    – Carl S Jan 17 '19 at 20:34
  • 3
    @CarlSteinhilber - -aoa works - I fixed the space after the -o parameter which throws this oddball CLI exception – SliverNinja - MSFT Mar 28 '19 at 22:56