Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.6: Create Symbolic Links via Services Desktop
Snow Leopard only hintOne of the things that makes me have to fire up the Terminal in Mac OS X is to create symbolic links. In Snow Leopard though, it is possible to use Automator to create a Service so you can simply create the links using a contextual menu in the Finder, and put it much like an alias wherever you need it.

You can download the Automator Service here. Once downloaded, open it in Automator, then 'Save As...' to save it in your ~/Library/Services folder.

The work in the Service is primarily done using the following bash shell script:
for f in "$@"
do
 curFolder=`dirname "$f"`
 linkFile=`basename "$f"`
 fileSuffix="link"
 fileExists=`ls -d "$f $fileSuffix"`
 fileNumber=0

 until [ $fileExists=="" ]; do
  let fileNumber+=1
  fileSuffix="link $fileNumber"
  fileExists=`ls -d "$f $fileSuffix"`
 done

 echo "$f $fileSuffix"
 ln -s "$f" "$f $fileSuffix"
done


[crarko adds: I tested this, and it works as described. The Automator Service code is mirrored here. I know there are other Services around that do this function, but options are good.]
    •    
  • Currently 2.75 / 5
  You rated: 4 / 5 (16 votes cast)
 
[14,459 views]  

10.6: Create Symbolic Links via Services | 4 comments | Create New Account
Click here to return to the '10.6: Create Symbolic Links via Services' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.6: Create Symbolic Links via Services
Authored by: renaultssoftware on Aug 12, '10 12:40:26PM

Uh, doesn't the Make Alias command work much the same?

---
http://groups.google.com/group/applescripters/
http://qgf.in/
http://www.kompilesoft.info/



[ Reply to This | # ]
10.6: Create Symbolic Links via Services
Authored by: ddauerbach on Aug 12, '10 12:59:54PM

No.
Big functional difference between aliases and symbolic links. Major practical consequence for me is that dropbox respects symlinks but not aliases. (I.e., fill your dropbox folder with symlinks rather than actually move folders there. Much better.)



[ Reply to This | # ]
10.6: Create Symbolic Links via Services
Authored by: asmeurer on Aug 12, '10 08:18:50PM

Hey! Cool tip on the DropBox thing.



[ Reply to This | # ]
10.6: Create Symbolic Links via Services
Authored by: PatrickS on Aug 18, '10 01:50:18AM
Great tip, thanks.

A slightly nicer and more shell-like version of the script could look like this:

fileSuffix=".link"
for f in "$@"; do
    while [ -e "$f$fileSuffix${fileNumer:+.$fileNumer}" ]; do
        let fileNumer+=1
    done

    echo "$f$fileSuffix${fileNumer:+.$fileNumer}"
    ln -s "$f" "$f$fileSuffix${fileNumer:+.$fileNumer}"
    fileNumber=
done


[ Reply to This | # ]