Windows – Batch repacking zip archives into 7z

archivingbatchwindows 7

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.

Best Answer

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.

Related Question