Apr 08, '10 07:30:02AM • Contributed by: TonyT
When I need a container of files, or of a directory that is already compressed (i.e. jpg images), there is no need to 'compress' into a zip file, so the following OS X Service will replicate the Compress 'right-click' with tar:
- Open Automator and select Service from the main screen.
- Set the 'Service Receives Selected' pop-up menu to Files or Folders, and set the 'in' pop-up to Finder.
- Drag Utilities » Run Shell Script into the workflow area.
- Set the 'Pass input' pop-up to as arguments.
- Delete all of the sample code, and replace with this:
Tarfile="$1.tar" count=1 cd "${@%/*}" if [ $# -eq 1 ]; then while [ -e "$Tarfile" ] do let count++ Tarfile="$1 $count.tar" done else Tarfile="Archive.tar" while [ -e "$Tarfile" ] do let count++ Tarfile="Archive $count.tar" done fi /usr/bin/tar -chf "$Tarfile" "${@##*/}" - Select File » Save and name your new Service (Package into Tar or whatever).
- Quit Automator and try your Service in the Finder with a selection of files.
