views:

122

answers:

4

We are a network of Mac computers. I would like to send email addresses to colleagues with links to files on network locations. I made the following applescript:

tell application "Finder" set uuu to URL of the first item of (get the selection) set the clipboard to uuu end tell

which puts the URL of the currently selected file into the clipboard, which can then be pasted into the message (using the Add Link menu item), providing, for example:

file://localhost/Volumes/Commerciale/Clienti/

unfortunately these links do not work. If I select Go To Folder from the menu item, I can get to the folder using an afp:// type url. Is there any way to get this via applescript like I do with url above?

Thanks

+1  A: 

Are the volumes already mounted on the email recipients' Mac? Netink makes a URL that is clickable in Mail. I don't have an AFP share here to test this:

tell application "Finder" to set netlink to URL of (get selection as alias)
songdogtech
Pardon a possibly lame question, but what is netlink? An application? A scripting extension? A link would be keen. Thanks
Philip Regan
After trying both this code and mmcgrail's, this doesn't work (at least for me (and mmcgrail)). The link in the sent email is a clickable link, but it goes nowhere, and I have the target volume mounted as AFP. More information is really needed here.
Philip Regan
looks like netlink is just a variable name in the example above.
stib
A: 

Not "automagically" as far as I know. The URL and POSIX path properties only returns the shared directory and not the volume itself. If you use the URL given to you by Applescript, only Applescript can still resolve it. (I get the impression the OS or Applescript is just iterating down the mounted volumes finding the file) You'll need to manipulate the path string to get the format you need.

Philip Regan
A: 

here is an expanded version of songdogtech's post

  tell application "Finder"  to set netlink to URL of (get  selection as alias)

  tell application "Mail"
     launch
     set newMessage to make new outgoing message with properties {subject:"network link", content:netlink, visible:true}

     -- Add in code for recipient, etc, etc
     --send newMessage
  end tell

but that still doesn't seem to work lol

mcgrailm
A: 

I have solved with this script:

on urlToPOSIXPath(theURL)
    return do shell script "python -c \"import urllib, urlparse, sys; print urllib.unquote(urlparse.urlparse(sys.argv[1])[2])\" " & quoted form of theURL
end urlToPOSIXPath

tell application "Finder"
    set uuu to URL of the first item of (get the selection)
    set pp to my urlToPOSIXPath(uuu)
    set the clipboard to "file://" & pp
end tell
CRP