Skip to content

Instantly share code, notes, and snippets.

@radio412
Forked from anonymous/gist:2211017
Last active January 17, 2017 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save radio412/036484376a56f09e1a4a to your computer and use it in GitHub Desktop.
Save radio412/036484376a56f09e1a4a to your computer and use it in GitHub Desktop.
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 mylocation to searchReplace(myClip, "<", "")
set mylocation to searchReplace(mylocation, ">.", "")
set mylocation to searchReplace(mylocation, ">", "")
set mylocation to searchReplace(mylocation, "\\", "/")
set mylocation to "smb:" & mylocation
# convert Windows network drive paths to SMB addresses EXAMPLE:
set mylocation to searchReplace(mylocation, "smb:W:", "smb://10.0.0.1/shares")
# check if the person who gave you the windows link used a lowercase drive letter:
set mylocation to searchReplace(mylocation, "smb:w:", "smb://10.0.0.1/shares")
# fix issue with spaces
set mylocation to searchReplace(mylocation, " ", "%20")
tell application "Finder"
open location mylocation
end tell
# after setting the location, set Finder to topmost, or delete this section if you dont want that.
tell application "Finder"
activate
end tell
return input
end run
@radio412
Copy link
Author

radio412 commented Dec 9, 2014

This is an AppleScript to allow Windows users to send fully qualified windows network drive paths in an email that can be opened on a Mac. This is a fork. Instructions on how to use it are at http://apple.stackexchange.com/questions/46129/how-to-translate-between-windows-and-mac-style-file-locations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment