Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have many zip archive files that I would like to re-pack into 7z archive format, as that would save me a lot of space. How do I batch-repack those files on a Windows 7 computer?

I tried doing this via GUI version of 7-zip archiver, but I didn't find a corresponding function. WinRar has a "Convert" functionality, but it doesn't archive into 7z format.

I'm not asking exclusively for a solution involving Batch-file scripting.

share|improve this question
    
Uhmm, write a batch file that uses 7-zip? What have you tired already? Where are you getting stuck? –  Ƭᴇcʜιᴇ007 Sep 15 '13 at 18:02

3 Answers 3

You can use the 7zip command line (detailed examples here) to first extract all files/folders (using the e command) and then re-compress them to 7z (using the a command).

If you plan on repeating this operation, consider capturing the command lines in a .bat/.cmd file.

And always test on a small directory before trying on a huge number of archives!

share|improve this answer

Here is a command line that will do it for you, this assumes that the zip files are in the same directory as 7z.exe:

for %F in (*.zip) do ( 7z.exe e -y -o%~nF.tmp %F * & pushd %~nF.tmp & ..\7z.exe a -y -r -t7z ..\%~nF * & popd & rmdir /s /q %~nF.tmp )

share|improve this answer
    
I'm still struggling to make this work for me. –  user1306322 Sep 15 '13 at 19:26
    
What problem are you having? The above snippet assumes your .zip files are in the 7-zip program directory. You should run that command from an elevated command prompt. –  Clint Priest Sep 15 '13 at 19:47
    
Alternatively put your zips in an unprotected directory, replace the 7z.exe references with the full path to the 7z.exe. Then from a regular cmd prompt cd into the dir with your zip files and run the modified snippet. –  Clint Priest Sep 15 '13 at 19:49
    
I just did it and it compresses the files in the folder the bat file is being run from (1 test zip archive and the bat file itself). After which it says 2 times "cannot find specified file". –  user1306322 Sep 15 '13 at 19:53
    
Well, I tried for %%F in (*.zip) do ( "C:\Program Files\7-Zip\7z.exe" e -y -o%%~nF.tmp %%F * ) and it says cannot find archive for all zip files in folder. –  user1306322 Sep 15 '13 at 20:43
up vote 1 down vote accepted

This is my own take on the problem:

for %%F in (*.zip) do ( "C:\Program Files\7-Zip\7z.exe" x -y -o"%%F_tmp" "%%F" * & pushd %%F_tmp & "C:\Program Files\7-Zip\7z.exe" a -y -r -t7z ..\"%%~nF".7z * & popd & rmdir /s /q "%%F_tmp" )

Save this to a zip to 7z.bat file, place it into the directory with all the zip files you want to convert and double-click it there.

Thanks to Clint Priest for the base code.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.