So I want to create a script that enables me to compresses each folder into its own zip archive and not into a one big zip file.
As an example, I've got a directory:
+ MyDirectory/ | | | + Folder_01/ | | | + Folder_02/ | | | + Folder_03/ |
When I'm done running the script under MyDirectory
then I would have a zip file of each Folder which is inside MyDirectory
: Folder_01.zip
, Folder_02.zip
and Folder_03.zip
. I know some BASH but this is something I can't figure out.
How can this be done?
Kind regards.
1: create a new folder, then select folder that you would like to put into archive folder and drag to the new folder, then a prompt box popped out there, click Yes. 2: After you move the 60 folders to the new folder, drag the new folder to the archive Folder.
Steps to zip folders into multiple files:Open Winzip. From the WinZip file pane select the file you want to split. Next, click Add to Zip and make sure to select the Split option. Indicate where you want your zip files to be saved.
for i in * do [ -d "$i" ] && zip -r "$i.zip" "$i" done
You walk through all the directories and create zip for each of them.
Or even more concise:
for i in */; do zip -r "${i%/}.zip" "$i"; done
(thanks to damienfrancois for suggestion).
here
for i in */; do tar -czvf "${i%/}.tar.gz" "$i"; done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With