Monthly Archives: June 2010

Open Windows Share

As a Mac user in a Windows world, I can get along just fine. I can share files with my colleagues, collaborate documents, or communicate. However, one of the annoyances I face has to do with how Windows and Mac references SMB shares. Windows uses the \\server\share notation while Mac uses smb://server/share. I often receive emails such as one below:

Hello Hai,
Please review the latest document is at \\community\docs\readme.txt and let me know what you think.
– Da boss

I wish I can just highlight the share and open it in the Finder, but it is in a different language. Parlez-vous Anglais? After putting up with this problem for too long, I finally had enough and decided to do something about it. My solution involes a little automation, add to it some sed shell script and mix well. Here is how.

Create a New Service


Start Automator, select Service and click Choose.

Add a Run Shell Script Action


Make sure that the top said, "Service receives selected text in any application" (see picture above). From the Library column on the left, select "Utilities", then select "Run Shell Script" in the next column. Next, type the following script:

open $( echo "$1" | sed ‘s:\\:/:g;s/^/smb:/’ )

Save this automation action as "Open Windows Share" or any name you choose.

Try It Out


Select the text containing the Windows-notation, then select the application menu (the name of the application at the top left corner), Services, Open Windows Share. The document you selected should be open.



This automator action employs the sed command to transform the selected text based on the following two rules: a) replace all back slashes "\" with forward ones "/", and b) slap a "smb:" in front. The effect of this transformation turns a Windows-notation to Mac (or Unix, for that matter). The automation action resides at ~/Library/Services directory.