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

This approach works from the command line:

osascript -e 'tell application "Finder" to make alias file to alias "imac:Users:vy32:current:cyber.txt" at "imac:Users:vy32:foobar"'

Where foobar is a directory in my homedir.


For everyone struggling with the AppleEvent handler failed error:

make alias doesn't work like ln -s, you don't have to specify the destination file, you have to specify the destination directory, the filename of the alias is the name of the source file/folder.

Example:

osascript -e 'tell application "Finder" to make alias file to (POSIX file "/Applications/Mail.app") at (POSIX file "/Users/leandros/Desktop")'

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"'