Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Translate and open Windows network location strings Network
I saw this tip and it gave me the idea to write a script to solve an annoyance I've been having for a while: I work in a mostly Windows workplace and I often get emails with windows oriented paths:
\\servername\volumename\directory\directory
I always thought it would be nice to be able to just click on the link like you can in Windows. Well, this isn't quite that nice, but it's better than having to go through the steps of navigation to the directory.

Here's the AppleScript:
set myClip to the clipboard
set mytext to searchReplace(myClip, "<", "")
set mytext to searchReplace(mytext, ">.", "")
set mytext to searchReplace(mytext, ">", "")
set findIt to "\\"
set replaceIt to "/"
set mylocation to searchReplace(mytext, findIt, replaceIt)
set mylocation to "smb:" & mylocation

tell application "Finder"
	open location mylocation
end tell

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
Note: I got the searchReplace handler code from MacCentral

Save this AppleScript as an application, and to use, just copy the Windows path into into the clipboard and launch the script.
    •    
  • Currently 2.50 / 5
  You rated: 4 / 5 (4 votes cast)
 
[8,061 views]  

Translate and open Windows network location strings | 2 comments | Create New Account
Click here to return to the 'Translate and open Windows network location strings' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Translate and open Windows network location strings
Authored by: HazMatt on Mar 29, '04 04:34:36PM
Since submitting this, I have found a bug: if there are spaces in the path, it will not work.
You will need to add this line to the script:

...
set mytext to searchReplace(mytext, " ", "%20")
before this line:
set findIt to "\\"
Unfortunately, if there are spaces you will only open the volume and not go down the full path. Any solutions to this issue will be appreciated.

-HazMatt

[ Reply to This | # ]

Translate and open Windows network location strings
Authored by: GaelicWizard on Mar 31, '04 05:48:18AM
by all rights
tell application "Finder"
really ought to be
tell application "System Events"

---
Pell

[ Reply to This | # ]