Linux: ZIP Multiple Directories Into Individual Files

0
646

earllinux-150If you have been trying to ZIP multiple directories into individual files, this simple command will do just that for you.

ZIP Without Sub directories

for dirname in */; do zip "${dirname%/}.zip" "$dirname"; done

ZIP With Sub directories

Specifying the -r parameter to the zip program it will also include any sub directories of the individual directories that you are creating the individual zip files for.


for dirname in */; do zip -r "${dirname%/}.zip" "$dirname"; done

LEAVE A REPLY

Please enter your comment!
Please enter your name here