I'm wanting to zip multiple folders at the same time, where each folder is it's own zip file. I'd like to create the zip without the _macosx or any other hidden files, and if possible have the zip file's extension changed to .cbz at the same time. That way I can just run one process on one entire folder and get them all done quickly.

I'm using Ubooquity to host my comics and it treats the files as corrupt if the _macosx file or any other hidden files are inside the zip file.

  • Do the target individual folders, that you want to (batch) zip individually, contain subfolders as well or just files within each target individual folder to be zipped? Commented Sep 28, 2017 at 23:01
  • There are no subfolders. I have one big folder (for example Spider-Man) Then inside that folder are folders for each issue. (Spider-Man 001, Spider-Man 002, etc) Inside those folders are the jpg images. 001.jpg, 002.jpg, etc.
    – Ryan Boles
    Commented Sep 29, 2017 at 2:19
  • So, if in Finder you went into the Spider-Man folder and selected Spider-Man 001, Spider-Man 002, etc, then right-click and select Create CBZ Zip Archive, and it then created Spider-Man 001.cbz, Spider-Man 002.cbz, etc in the Spider-Man folder, you'd be happy with that? Of course each zip archive will not have the __MACOSX folder or hidden files like .DS_Store, .localized, or other exclusions added as/if necessary. Commented Sep 29, 2017 at 2:48
  • Yeah, I'd be happy if I could zip them up by right clicking and select Create CBZ if it didn't include the _macosx and .ds_store files. When I just use the default compress option it will include those.
    – Ryan Boles
    Commented Sep 29, 2017 at 3:29

1 Answer 1


Here is an Automator Service that uses as single Run Shell Script action to handle the process.

  • In Automator, select: File > New > Service

  • Set: Service receives selected folders in Finder

  • Add a Run Shell Script Action

    • Settings: Shell: /bin/bash and Pass input: as arguments
    • Replace all of the default code with the code show further below.
  • Save the Automator Service giving it an appropriate name, e.g.: Create CBZ Zip Archive

Now in Finder, select the target folder(s) that you want an individual zip archive, with a .cbz extension for each selected folder, then right-click and select Create CBZ Zip Archive, from the services section of the context menu.

Code for Run Shell Script Action:

for d in "$@"; do
    if ! cd "$(dirname "$d")"; then exit; fi
    if ! d="$(basename "$d")"; then exit; fi
    if [[ ! -e "${d}.cbz" ]]; then
        if ! zip -r "${d}.cbz" "$d" -x \*.DS_Store \*.localized; then exit; fi


  • As coded, it only creates the filename.cbz zip archive file if the file does not already exist.
  • It creates the filename.cbz zip archive file in the same folder containing the selected folder(s).
  • It's written in a manner that if an error occurs with any of the steps taken, it exits the script without notification. Error handling can be modified as needed/wanted.
  • By default, zip will not include the __MACOSX folder and if you find there are other hidden files besides .DS_Store and .localized, although you shouldn't run in to the latter in this use case, you can add additional exclusions to the zip command.
  • As is, the only indication the script has finished is when the Automator Service Gear Icon on the Menu bar has disappeared. Some other form(s) of completion notification can be added to the script and or the workflow of the Automator Service extended with additional actions as appropriate, needed/wanted.
  • As is, it's no frills, however it does what it's programed to do.
  • This works perfectly for my needs. Thank you so much!
    – Ryan Boles
    Commented Sep 29, 2017 at 13:31
  • Is there a way to add the service to show up when you right click in the default menu or do I always have to hover over the services tab?
    – Ryan Boles
    Commented Sep 29, 2017 at 13:32
  • @Ryan Bolesm How many services do you have on the Services context menu in Finder? You also could assign it a shortcut, e.g.: ⇧⌘B Commented Sep 29, 2017 at 13:52
  • I've got 1. Folder Actions Setup... 2. Omnifocus 2 3. Add to Wunderlist 4. Rename 5. CBZ Zip 6. Reveal in finder. How do I add it as a shortcut?
    – Ryan Boles
    Commented Sep 29, 2017 at 13:57
  • @Ryan Boles, IIRC Once you have more then 4 services it creates Services as a submenu on the context menu. If you run the following command in Terminal, it should show all directly on the context menu: defaults write -g NSServicesMinimumItemCountForContextSubmenu -int 100001 Then killall Finder for the change to take effect. To add a keyboard shortcut: System Preferences > Keyboard > Shortcuts > Services Commented Sep 29, 2017 at 14:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .