vote up 4 vote down star
2

Is there a way to get the same functionality as the unix command ln -s in the Mac OS X Finder (OS 10.5)? I want to be able to create symbolic links while working in Finder windows without opening the Terminal.

Note that the Make Alias command in Finder is not what I want because those aliases cannot be navigated in the Terminal (but links created with ln -s can be navigated by both the Terminal and Finder).

flag

6 Answers

vote up 3 vote down check

What about that: Create symbolic links in the Finder via AppleScript ?

link|flag
1  
The 2nd comment at that link, left by jonn8n, gives exactly the functionality I was looking for. Although, I'm a bit surprised this is not possible within Finder itself. – Michael Schneider Aug 18 at 11:09
vote up 3 vote down

SymbolicLinker will do exactly what you're looking for, and it's free.

alt text

link|flag
vote up 2 vote down

An applescript at the link provided by user nuc answered my question. Here is the applescript reproduced in case that link disappears.

I preferred the script given by the commenter jonn8n, which was also reproduced as Macworld article.

on run
    open {choose file with prompt ¬
    	"Choose a file to create a symbolic link:" without invisibles}
end run
on open the_files
    repeat with i from 1 to (count the_files)
    	try
    		set posix_path to POSIX path of (item i of the_files)
    		if posix_path ends with "/" then set posix_path to ¬
    			text 1 thru -2 of posix_path
    		do shell script "ln -s " & quoted form of posix_path ¬
    			& " " & quoted form of (posix_path & ".sym")
    	end try
    end repeat
end open

I saved this as an application using Script Editor and dragged the application to the Finder sidebar so I can now create symbolic links by dragging files or folders onto the application icon.

link|flag
vote up 0 vote down

Isn't that just right click and Make alias?

link|flag
2  
No, because I cannot later navigate into that alias using the Terminal. I want exactly the same functionality as ln -s, which Make alias does not provide. – Michael Schneider Aug 18 at 9:39
vote up 0 vote down

A possible improvement on this script would be changing the run handler to use the currently selected files from the Finder, as so:

on run
    tell application "Finder" to set sel to selection
    open sel
end run
on open the_files
    repeat with i from 1 to (count the_files)
    	try
    		set posix_path to POSIX path of (item i of the_files as alias)
    		if posix_path ends with "/" then set posix_path to ¬
    			text 1 thru -2 of posix_path
    		try
    			do shell script "ln -s " & quoted form of posix_path ¬
    				& " " & quoted form of (posix_path & ".sym")
    		on error
    			try
    				do shell script "ln -s " & quoted form of posix_path ¬
    					& " " & quoted form of (posix_path & ".sym") with administrator privileges

    			end try
    		end try
    	end try
    end repeat
end open

You could also edit [application]/Contents/Info.plist to add

<key>LSUIElement</key>
<true/>

Just before the last </dict>. This would mean the app would run in the background, and wouldn't come to the front when you clicked on it.

link|flag
vote up 0 vote down

Also, in Snow Leopard where SymbolicLinker doesn't work, you can create a Service with Automator to do either the Terminal command or AppleScript to create a symbolic link.

link|flag

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.