4

For an office with mostly Windows workstations and a few OS X workstations, what's the easiest way for the Mac users to translate to and from a Windows-style file paths?

For example, to automatically translate \\fileserver01\client-files\client01\comp.psd, if sent in an email, to //fileserver01/client-files/client01/comp.psd?

6

This site has a way to translate into a mac network location and open it: http://hints.macworld.com/article.php?story=20040322155331393

So you could easily save that as a text service and be able to select a windows network location, right-click it, and have it translated and opened.

I imagine you could sort of reverse the function and translate back into a windows network location string.

Here's how to set up a text service/quick action to convert to a Mac path and open it in Finder:

  • Open up Automator
  • Choose "Service" (called "Quick Action" in macOS Mojave)
  • Drag a "Run AppleScript" item from the library into the main area on the right.
  • Copy and paste this AppleScript into it: https://gist.github.com/2211017 (it wouldn't properly format in here)
  • Save it under "Convert and Open Windows Path" or whatever you like.
  • Select a path in an application, right-click it, and look for the service you created (it might be under a "Services" sub-menu)

Here's what your Automator service should look like: Automator Service Example

  • 2
    This is so close to a great answer. If you brought that AppleScript in to the answer from the reference site and then walked through how to set it up as a service you'd have a stellar answer. – Ian C. Mar 27 '12 at 0:11
  • @IanC. were you referring to the first or second site? I'll do that. – penguinrob Mar 27 '12 at 0:12
  • The first site. The MacWorld Hints page. – Ian C. Mar 27 '12 at 0:13
  • Thanks for the suggestions Ian! Now I've learned how to make text services which I can already think of some uses for. – penguinrob Mar 27 '12 at 0:36
  • 1
    @penguinrob i suspect "Service" has been changed to "Quick Actions": awesomescreenshot.com/image/3639839/… – Mau Oct 2 '18 at 0:43
0

I know this is an old exchange, but it still works. I forked the code to show an example of converting a network drive path to an SMB protocol with a server IP address.

This is helpful if windows users have a lettered network drive such as W:\a\really\tedious\folder\path

https://gist.github.com/jberg412/036484376a56f09e1a4a

Thanks for the original script PenguinRob.

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

You must log in to answer this question.

protected by Community Aug 24 '16 at 18:45

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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