I am trying to create an Automator service that allows a user to highlight a link that has been emailed by a Windows user, and have it open to the equivalent SMB share on a Mac.
For example:
Windows user sends this link in an email: file://ad.schoolname.edu/newyork/GroupShares/Central_IT
Mac user would open up this file share to go to same location: smb://172.16.4.69/NewYorkGroupShares/Central_IT
This is what I have put together in Automator, but all it does is open "Macintosh HD" when I highlight the Windows file path and run the service. Any ideas? Thanks!:
on searchReplace(theText, SearchString, ReplaceString)
set OldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to SearchString
set newText to text items of theText
set AppleScript's text item delimiters to ReplaceString
set newText to newText as text
set AppleScript's text item delimiters to OldDelims
return newText
end searchReplace
on run {input, parameters}
set myClip to the input
set winPath to "file://ad.schoolname.edu/newyork/GroupShares/Central_IT"
set macPath to "smb://172.16.4.69/NewYorkGroupShares/Central_IT"
set mylocation to searchReplace(myClip, winPath, macPath)
do shell script "open " & quoted form of mylocation
return mylocation
end run
file://
is not a valid URL scheme (in Windows or MacOS), as a file URL will either have one or three slashes after the colon, never two. Also, a file URL will always point to a local resource, whichad.schoolname.edu
is not. If there’s a Samba accessible from MacOS using ansmb://
URL, Windows should be able to use the same URL to access the remote share. In the case of a local resource on the Windows machine, then Windows would share a link that looks like\\PC-NAME\SharePoint\…
.172.X.X.X
is obviously just a private IP address on your local network, which is about as useful to anyone as telling you mine is192.168.1.202
. And the Windows link which looks remote will require authentication if it’s accessible over the internet but not intended for public viewing.