Monday, November 17, 2014

7zip command to batch zip all folders and unzip all zip files

7zip is very usefull to do batch jobs through command line. I usually use these command and create a batch file for easy use later. Just simply put the command in text file and rename .txt as .bat.

This is command for batch unzip all zip files into each respective folders name:

@echo off
for /F "delims=" %%I IN (' dir /b /s /a-d *.zip ') DO (
    "c:\Program Files\7-Zip\7z.exe" x -y -o"%%~dpI\%%~nI" "%%I"
)
pause

This is command for batch zip all folders into each respective zips name:

for /d %%X in (*) do "c:\Program Files\7-Zip\7z.exe" a "%%X.zip" "%%X\"

No comments:

Post a Comment