Extract and overwrite existing files

13

3

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

Posted 2012-10-03T17:29:50.893

Reputation: 153

Answers

17

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

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

SeanC

Posted 2012-10-03T17:29:50.893

Reputation: 3 439

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 – 2012-10-03T19:24:38.163

2

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

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

Vikram Gondane

Posted 2012-10-03T17:29:50.893

Reputation: 21

1Welcome 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 – 2018-04-09T13:43:53.457

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 Steinhilber – 2019-01-17T20:34:37.390

1@CarlSteinhilber - -aoa works - I fixed the space after the -o parameter which throws this oddball CLI exception – SliverNinja - MSFT – 2019-03-28T22:56:36.180