Symbolic Links Made Simple

Today's Best Tech Deals

Picked by PCWorld's Editors

Top Deals On Great Products

Picked by Techconnect's Editors

Symbolic links are similar to aliases, in the sense that they are shortcuts that link to a specific file or folder. But symbolic links are often more useful than aliases: For example, if you put an alias in your Dropbox folder, it will sync just the alias file; put a sym link in that folder, and Dropbox will sync the original file that link points to. And aliases won't work in OS X's Unix-based tools, including Terminal; sym links will.

The Finder makes it easy to create aliases (Control-click, select Make Alias), but not to make symbolic links. For that, you usually have to turn to Terminal. We've shown you one way to create sym links within the OS X GUI, using an AppleScript application. But MacOSXHints reader RickoKid came up with another way, using a shell script and Automator.

Start by opening Automator and selecting Service from the list of templates. Next, select Files or Folders from the Service Receives Selected drop-down and from In. Drag the Run Shell Script action from the Utilities section of the Actions library. Select As Arguments from the Pass Input menu, then paste the following script into the Run Shell Script window (replacing any text that might be there already):

for f in "$@"


curFolder=`dirname "$f"`

linkFile=`basename "$f"`


fileExists=`ls -d "$f $fileSuffix"`


until [ $fileExists=="" ]; do

let fileNumber+=1

fileSuffix="link $fileNumber"

fileExists=`ls -d "$f $fileSuffix"`


echo "$f $fileSuffix"

ln -s "$f" "$f $fileSuffix"


Below that, drag the View Results action from the same library. Save the workflow (it should automatically be added to ~/Library/Services), giving it whatever name you want (Create Sym Link, for example). That done, you should be able to Control-click on a file in the Finder, then select your service from the Services submenu; a sym link (with the word link appended to the filename) should appear in the same folder as the original file.

If you don't want to do all that copying-and-pasting, you can download the service and save it directly to the Services folder. You could, of course, also make that earlier AppleScript we told you about into a service. Or you could download a dedicated app like SymbolicLinker to do the job.

This story, "Symbolic Links Made Simple" was originally published by Macworld.

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