How can I create a .zip file for each folder within another folder?
Under the folder images\
, I have the following folders:
Usa\
Italy\
Japan\
etc..
I want a script that creates a .zip
for each of these folders, so I have usa.zip
, italy.zip
, japan.zip
.
How can I do that?
Solution 1:
You can use Winrar for this.
Select all your folders, right click and select Add to archive
. Now select the option Put each file to separate archive
under the tab Files
:
Click OK and you're done. If you want .zip files instead of .rar, just select ZIP
in the General
tab under Archive format
.
Solution 2:
I assume this is Windows, as you are using backslashes.
Get 7za.exe (the command-line version of 7-zip) and put it in your %PATH%
.
Then run this within your Images\
directory:
for /f "tokens=* usebackq" %G in (`dir /b /a:d "%cd%"`) do 7za a -r -tzip "%~G.zip" "%~G"
Or in a batch script:
for /f "tokens=* usebackq" %%G in (`dir /b /a:d "%cd%"`) do 7za a -r -tzip "%%~G.zip" "%%~G"