Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create a Macintosh Finder Alias From the Command Line?

I am trying to create a Finder Alias from the command line or from a Python program. I have searched the web[1][2][3] and found this bit of applescript:

$ osascript -e 'tell application "Finder" to make new alias at POSIX file "/Users/vy32/cyber.txt" to POSIX file "/Users/vy32/a/deeper/directory/cyber.txt"'

Unfortunately, it gives me this error:

29:133: execution error: Finder got an error: AppleEvent handler failed. (-10000)

[1] http://hayne.net/MacDev/Bash/make_alias

[2] https://discussions.apple.com/thread/1041148?start=0&tstart=0

[3] http://hintsforums.macworld.com/showthread.php?t=27642

What am I doing wrong?

like image 670
vy32 Avatar asked Aug 16 '11 00:08

vy32


People also ask

Is an alias on a Mac the same as a shortcut?

(2) In the Mac, an alias is an icon that points to a program or data file. The Mac counterpart to a Windows "shortcut," an alias can be placed on the desktop or stored in other folders, and clicking the alias is the same as clicking the original file's icon.


1 Answers

about your message, try to look at Console.app. May be source file does not exists. This helps me when I try to make Xcode 4.3+ applications visible. I've found working code:

$ osascript -e 'tell application "Finder" to make alias file to POSIX file "/file/to/make/link/from" at POSIX file "/folder/where/to/make/link"'

for example:

$ osascript -e 'tell application "Finder" to make alias file to POSIX file "/Applications/Xcode.app/Contents/Applications/OpenGL ES Performance Detective.app" at POSIX file "/Users/mylogin/Applications"'
like image 84
Eir Nym Avatar answered Sep 29 '22 08:09

Eir Nym