A script to convert and mount Windows server paths

Apr 04, '05 10:05:00AM

Contributed by: oliverlangan

I work in a Windows-dominant environment, and am annoyed at always getting 'links' in emails that are really Windows filepaths, like this one:

\server\share\point\path\to\file or folder
These usually have spaces in them, and can point to either a file or a folder. So I created a small Perl script to take a string from the clipboard, mount the correct sharepoint (if necessary), and then open the directory or file to which the original path points:
#!/usr/bin/perl

$smburl = `pbpaste`;
$smburl =~ s"\n" "g;
if ($smburl =~ m"^\\\\([^\\]*)\\([^\\]*)\\(.*)") {
  my ($server, $share, $path) = ($1, $2, $3);
  if (! -d "/Volumes/$share/") {
    system("osascript -e 'mount volume \"smb://$server/$share\"'");
  }
  $path =~ s"\s*$"";
  $path =~ s"\\"\/"g;
  $path =~ s"\s"\\ "g;
  system("open /Volumes/$share/$path");
}
After creating this, I wrapped the application up with Platypus. Now when I get a Windows path in email, I select it, copy it, and use LaunchBar to open my ConvertServerPath application.

Comments (4)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20050401212406724