Quickly create .tar files in Finder

Today's Best Tech Deals

Picked by Macworld's Editors

Top Deals On Great Products

Picked by Techconnect's Editors

You probably know that you can quickly create a compressed file archive in Finder by selecting the files to be compressed, Control-clicking, and selecting Compress number Items from the contextual menu. What if you want to package a bunch of files together in one file, but don’t necessarily need to compress them? MacOSXHints.com reader TonyT has a solution:

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 Run Shell Script from the Utilities section of the actions library into the workflow area. Set Pass Input to As Arguments. Replace the sample code in the input area with this:

 cd "${@%/*}"
 if [ $# -eq 1 ]; then 
   while [ -e "$Tarfile" ]
      let count++
      Tarfile="$1 $count.tar"
   while [ -e "$Tarfile" ]
     let count++
     Tarfile="Archive $count.tar"
 /usr/bin/tar -chf "$Tarfile" "${@##*/}"

Select File -> Save and name your new Service (Package into Tar or whatever you want). Quit Automator, select some files in Finder, then Control-click (or right-click) and select your new service from the Services submenu.

The service will create the .tar file in whatever folder the selected files were in. You can, of course, rename and move it however and wherever you wish.

Note: When you purchase something after clicking links in our articles, we may earn a small commission. Read our affiliate link policy for more details.
Shop Tech Products at Amazon