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

media_1276487315003.png

Start Automator, select Service and click Choose.

Add a Run Shell Script Action

media_1276487436039.png

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

media_1276487890700.png

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.

Discussion

media_1276488775456.png

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s