2

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
9
  • What do you mean by "user to highlight a link"?
    – sfxedit
    Commented Jul 27, 2021 at 19:21
  • 1
    I mean for the user to highlight the Windows file path that was emailed to them with their cursor. This would then be the input that the Automator service would use. Commented Jul 27, 2021 at 20:45
  • There’s something not right here. 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, which ad.schoolname.edu is not. If there’s a Samba accessible from MacOS using an smb:// 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\….
    – CJK
    Commented Jul 28, 2021 at 1:42
  • I’d recommend double-checking and providing accurate examples of the URLs you’re working with. There’s really no point trying to obfuscate the URLs: 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 is 192.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.
    – CJK
    Commented Jul 28, 2021 at 1:48
  • "file://" is the format Outlook for Windows will output into an email if you use the "Link" function under the "Insert" tab and navigate to a file in a group share and insert it. This is how a particular department with mostly Windows users emails file paths to each other. Unfortunately they are not able to be opened by our Mac users. Commented Jul 28, 2021 at 13:12

1 Answer 1

-1

This is working for me, and hopefully it adapts to your situation.

  • Given the url: file://syd-fs1/des&Comms/3.%20DESIGN%20DEPT/
  • It decodes it: file://syd-fs1/des&Comms/3. DESIGN DEPT/
  • Then replaces 'file://syd-fs1/' with '/Volumes/'

Use a “Run Javascript” step in an Automator workflow:

function run(input, parameters) {
    var app = Application.currentApplication();
    app.includeStandardAdditions = true;
 
    let decoded = decodeURI(input);
    let path = decoded.replace('file://syd-fs1/', '/Volumes/')
    
    return path;
}

After this step, add a “Reveal Finder Items” step to the workflow.

For this to work, the SMB share must already be connected/mounted.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .