Got a wild hair to solve this problem since it's been bugging me… first, I'll recap, then provide a solution +:
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”
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: http://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 scripts: