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?
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
Are the volumes already mounted on the email recipients' Mac? Netlink 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)
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.
here is an expanded version of markratledge'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
精彩评论