4

Wanted to share perhaps a more thorough answer to this question: How to translate between Windows and Mac -style file locations?

But since I'm new and got no cred on this site, I'm posting as new question - sorry about that... just wanted to give back since the answer the above was helpful, but still required some hacking I wanted to save others the hassle.

PROBLEM

From a Mac, I want to copy a file path on a network share into an email so that its clickable by poor Windows recipients. Currently, I copy/paste the path, e.g.: smb://servername/MLS/Timbers/IrrefutableProofTimbersAreBestTeamInMLS.pdf

into an email, then manually convert it to a Windows path: \\servername\MLS\Timbers\IrrefutableProofTimbersAreBestTeamInMLS.pdf

But that’s a stupid thing to do over and over, so I found some examples online (this forum and others) and hacked it until I got it to work a few ways (see below).

A related problem is when Windows users send me a file path and I want to quickly access it. Currently, I manually navigate to it by translating the path in my little head, which hurts. So, I reversed the hack above and added a call to open the folder to the file.

SOLUTION

In Mac OS Automator I created three Apple scripts that run as a service. This enables me to select a path, right-click and choose the appropriate service from the “Services…” menu, which I named:

  • “Convert Windows to Mac path and open it”
  • “Convert Windows to Mac path”
  • “Convert Mac to Windows path”

enter image description here

DETAILS

 **Script: “Convert Windows to Mac path and open it”**

 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 mytext to searchReplace(myClip, "<", "")
            set mytext to searchReplace(mytext, ">.", "")
            set mytext to searchReplace(mytext, ">", "")
            set findIt to "\\"
            set replaceIt to "/"
            set mylocation to searchReplace(mytext, findIt, replaceIt)
            set mylocation to "smb:" & mylocation
            tell application "Finder"
                open location mylocation
            end tell
            return input
 end run

 -- Thanks to: https://apple.stackexchange.com/questions/144916/how-to-change-filepath-structure-using-automator-windows-to-mac --


 **Script: “Convert Windows to Mac path”**

 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 mytext to searchReplace(myClip, "<", "")
            set mytext to searchReplace(mytext, ">.", "")
            set mytext to searchReplace(mytext, ">", "")
            set findIt to "\\"
            set replaceIt to "/"
            set mylocation to searchReplace(mytext, findIt, replaceIt)
            set mylocation to "smb:" & mylocation
            return mylocation            
 end run


 **Script: “Convert Mac to Windows path”**

 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 mytext to searchReplace(myClip, "<", "")
            set mytext to searchReplace(mytext, ">.", "")
            set mytext to searchReplace(mytext, ">", "")
            set mytext to searchReplace(mytext, "smb://", "\\\\")
            set findIt to "/"
            set replaceIt to "\\"
            set mylocation to searchReplace(mytext, findIt, replaceIt)
            return mylocation
 end run

Screenshots of the last script:

enter image description here

closed as too broad by nohillside Mar 13 '17 at 5:43

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    Welcome to Ask Different. - please put your solution in the answer section. – bmike Mar 12 '17 at 21:39

Browse other questions tagged .