Archive for July, 2010

Creating individual zip files from folders inside a directory

July 29, 2010 Leave a comment

I recently ran into a situation where I needed to make individual zip files from folders inside a directory. I was able to find a lot of guidance for one big zip file, but I needed each folder to have its own zip file for archiving purposes. I also wanted good compression, resource fork preservation, and be able to run a command that would search the directory and make zips for each folder it found. (The last requirement was because I didn’t want to run the command individually on the 137 folders that I needed to make archives of.)

Fortunately, I was finally able to find a way to use ditto to do what I wanted. This command will search a particular directory, check for folders and use ditto to make compressed zip archive files:

for f in /path/to/directory/*; do ditto -c -k -X “$f” “$”; done

This command uses the folder’s name when saving the zip archive, so a “folderA” inside the directory will be compressed as “”

Categories: Geeky, Mac OS X Tags:

Get every new post delivered to your Inbox.

Join 160 other followers

%d bloggers like this: