create alias through the terminal with a custom filename

Abdelhafid
New Contributor

Hey Everyone,

We placing symlinks on the desktop to a few mounted network shares to give the ability to save files to symlink on the desktop. We just noticed office 2011 on osx 10.8.5 doesn't seem to follow symlinks in the save dialog.

Aliasses do seem to work but we'd like to customize the name of the alias that is created like we are doing with symlinks (our sharenames don;t make sense to our end users and renames the shares isn't an option).

Im using the following command in a terminal to create an alias to a mounted networkshare

#!/bin/sh

osascript -e 'tell application "Finder" to make alias file to posix file "/Users/username/Library/ShareMounts/sharename" at desktop '

Applescript/Osascript isn't my area of expertise and google hasn't been helpful so far. Does anyone know of a way to specify a name when creating a alias?

3 REPLIES 3

mm2270
Legendary Contributor III

There may be a simpler way to have it all on one line, but the following seems to work

tell application "Finder"
    set mySource to POSIX file "/Users/Shared" as alias
    make new alias to mySource at desktop
    set name of result to "MyAlias"
end tell

You could wrap it into a HEREDOC format, like so:

/usr/bin/osascript << EOF
tell application "Finder"
set mySource to POSIX file "/Users/Shared" as alias
make new alias to mySource at desktop
set name of result to "MyAlias"
end tell
EOF

Abdelhafid
New Contributor

Thanks you much. I'll give this a try first thing in the morning and get back to you :D

Nix4Life
Valued Contributor

whoops wrong window, disregard
LS