Home > Geeky, Mac OS X > Creating individual zip files from folders inside a directory

Creating individual zip files from folders inside a directory

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” “$f.zip”; done

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

Categories: Geeky, Mac OS X Tags:
  1. June 14, 2016 at 6:57 am

    I am not sure this worked back in 2010 but now there is a simpler solution:
    Open the “Archive Utility.app” located in /System/Library/CoreServices/Applications/
    and change its preferences to use archive format: “Zip archive”
    Then you can just drag and drop the folders on it’s icon in the dock.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: