How to zip all directories in a dir recursively - a handy tool

chris (2006-05-13 22:55:59)
3433 views
0 replies
A quick script which uses the gnu zip utility to zip up all the directories in the current working directory as windows compatible zip files. The original directories are preserved and the zip files placed alongside. So if you have a load of directories in a given location, these can be zipped up into separate zip files by running the following script:
#!/bin/bash
# megazip by chris lacy-hulbert

for i in `ls -al | grep ^d | awk '{print $8}'| egrep -v '^\.'`
do
        echo "\narchiving dir "$i
        zip -r $i $i
done

simple as that. I've not tried this on other unices, but I suspect it'll work pretty generically so long as the shebang points correctly to a bash binary, and assuming gnu zip is installed and in the current path.

christo
comment