Make Symbolic LInks in the Finder Using AppleScript
As much time as I spend “under the hood” (as opposed to in the ’hood) in OS X, I’m surprised I haven’t encountered this problem before, which is: aliases made in the finder (with Command-L) are not navigable from the command line. I was shocked.
Having need for a quick-and-dirty way to make symbolic links in the GUI, I whipped up the following AppleScript. Copy the following code 1 and paste it into a new Applications > AppleScript > Script Editor.app window.
on open (docpath)
set docpath to docpath as text
set search_string to ":"
set replacement_string to "/"
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to the search_string
set docpath to text items of docpath
set AppleScript's text item delimiters to the replacement_string
set docpath to text items of docpath as text
set unixpath to "/Volumes/" & docpath
set AppleScript's text item delimiters to the oldDelims
end tell
end if
do shell script "ln -s " & quoted form of unixpath & " " & quoted form of unixpath & ".sym"
end open
Save the file as a “Run Only” application (with or without “Startup Screen”) or download a precompiled copy of the application.2 When one drops a file or folder onto the resulting application, a symbolic link will be made in the same directory as the file with the extension “.sym”.
20061201 UPDATE: My hint is now up at MacOSXHints.com, and you can check yourself for useful comments and/or modifications. I will post any modifications I find helpful.
For now, the editor of MacOSXHints.com, Rob Griffiths, has collated links to several other hints helpful to those of us who “work with symbolic links and aliases in Terminal and Finder.” One of those linked hints I found particularly useful as it provides an elegant means to cd into the directories to which system aliases point.