Create a zip file using an Automator Service

automatorcompressionserviceszip

I am trying to create a service in Automator in Mac OS X Mountain Lion. The command that I want to use is as follows:

zip zip-file.zip "$@"

And here is a screen capture of what I did:

enter image description here

It works. But two problems:

  1. zip-file.zip is placed in my home directory ~\. I want to place the zip file in where the original files are.

  2. zip-file.zip contains the folder structure of the specified files beginning from the root. I want to only include files, or just from the closest parent directory.

What should I do?

Best Answer

Why not just use the Create Archive action rather than shell scripting?

I created a quick one that has four steps.

  1. selects a folder (Ask for Finder Items - Folders only)
  2. selects the files (Get Folder Contents)
  3. filters the items to not selects any subfolders (Filter Finder Items)
  4. pass the files to the Create Archive action

enter image description here