Noob looking for a simple path conversion script - UNC to Unix-style

Hey there! I’ve been searching for something like this for about an hour, so either I’m not looking in the right place or it hasn’t been invented yet!

I’d like to run a script that takes a UNC-syntax path (Windows-style, i.e. \volume\folder\file) in selected text or from text copied to the the clipboard, change it to unix-style path (flip the slashes and remove double-backslashes so it’s /volume/folder/file) and then send that info to “Go to folder…” so that if someone sends me an UNC-style path in an e-mail, I can just run the script and have it open up a Finder window with that folder.

I’ve been using FilePathCM by Limit Point software to send UNC paths to Windows coworkers. It works great. All they have to do is drop the path into an address bar in Windows and they’re there. When they send me an UNC path, however, I either have to change the slashes manually and then select “Go to folder…” in the Finder, or just navigate through an average of 5-10 levels of folders manually… I find that both take about an equal amount of time and both, while not terribly time-consuming, are just annoying.

Anyone have a script that would do this, or would happen to know of any add-ons or utilities that I could get?

Thanks for your help!

Nick

Model: MacPro Quad 2.8
Browser: Safari 525.27.1
Operating System: Mac OS X (10.5)

Try something like this:

set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to "\\"
set thePath to text items of (get the clipboard)
set text item delimiters of AppleScript to "/"
set thePath to "" & thePath
set text item delimiters of AppleScript to prevTIDs
if thePath starts with "//" then set thePath to POSIX path of text 2 thru -1 of thePath

tell application "Finder"
	try
		reveal (thePath as POSIX file)
	on error errMsg number errNum
		display alert "Error: " & errNum message errMsg buttons {"Cancel"} cancel button 1
	end try
end tell

Hey there! Thanks so much for taking the time to do this.

I’m getting the following:

"Error: -10000

Finder got an error: AppleEvent handler failed."

Is there something I’m doing wrong?

Thanks again!

That’s probably because the path is incorrect.

As a guess, try using this line earlier in the script:

if thePath starts with "//" then set thePath to "/Volumes" & POSIX path of text 2 thru -1 of thePath