The missing link: symbolic and hard links in Mac OS X (Leopard) and a script to enable them
i’m still a bit surprised that you can’t create symbolic and hard links through the Leopard UI. Yes, you can create an alias, but not a link. Yes, you can open up Terminal and do it manually, but that’s not what Aqua’s all about. Surely?
A strange decision then, by Apple.
For those not in the know, an Alias differs subtly from a link in that an alias is invisible to command line tools. It exists only in Aqua’s scope (the UI).
Furthermore there is a difference between a symlink and a (hard) link.
Symbolic links are curious beasts: they are transient. Whereas an Alias is a link to a resource (ie. a file) a symlink is simply a link to a putative file called whatever in a specific location. So you can create a symlink then move the original, and the link is broken. And when you then try to open the symlinked file you will get this screen (at least in Aqua):
This behaviour is altered for a hard link: it will behave much more like an Alias.
For an example, type the following commands. this creates a directory in your home folder, a test file and a couple of links.
cd ~ mkdir symtest echo "I am a test file" >> test.txt cd symtest ln -s ../test.txt ./symlink.txt ln ../test.txt ./hardlink.txt |
Now you should have two files in your linktest directory. looking at them in Finder makes them appear like this:
and looking at them in terminal, by contrast, gives the following:

You will see that to all intents the hard linked file looks like a real file. But here’s the kicker: it’s not. It is just a link. Prove it to yourself by editing the file in linktest/ and then checking the original in your home directory.
And, moreover, a hard link will survive the file moving locations. Try it: move the test.txt file to the linktest directory and open up hardlink.txt. All still works fine. Do the same for symlink and the world ends.
So the conclusion to all of this is that hard links are rather more useful than symbolic links, although each serve their purpose. So why can’t I create proper hard links in the Leopard UI? Again: strange decision, Apple.
Anyway, with little bit of Automater trickery you can easily overcome this problem. And when I say little, I really mean it! Just do the following:
Launch Automater (if you don’t know where it is then use Spotlight).
If you’re in the wizard select the Files & Folders item and the other menu items as shown below:
and hit Choose.
now select Utilities from the left hand list, and Run Shell Script from the next one. Double click on the Run Shell Script item (or drag to the right hand pane) to place the action in the Automator flow. Note that I have also changed the right hand option for Pass Inputs to “as arguments”:
Now, we need to add the actual script itself. It’s a one liner and you first need to delete all the code that is there; and then replace with:
ln "$@" "$@.link" |
This creates a hard link. if you want to create a symbolic link (for example on a directory) then change the above line to
ln -s "$@" "$@.link" |
Then save it by clicking the File -> Save As Plugin.
If you’re creating a symbolic linker, perhaps call it Create Symbolic Link instead
Now you’re done.
To test it, go to a Finder window and select a file:
and then you’ll find the newly created link in the Finder window. You can move this elsewhere in the file system and call it what you like. Note that it inherits the original’s file stats too.
and there you go. The actual process of setting up this script is well under a minute. It just seems longer/more complex due to the screenshots! Promise!







Is there a way to make thiswork for more than one file at a time?
@Curious Inquirer:
sure. change the script to this instead: