Friday 31 January 2020

windows 7 - Batch repacking zip archives into 7z


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.



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.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...