archive about

OSX service to rewrite my intranet links

At the office we have a mixed Windows/OSX environment.

There is also a shared network storage with multiple mount points. In Windows, a link to a file on the server, will look like N:\TempFiles\company\project\ while on a Mac, the same link will look something like /Volumes/TempFiles/company/project/. So when a colleague send me the link to his latest presentation from Windows, I have to manually follow the path.

That's why I wrote a simple OS X service that does that automatically. I just copy (cmd-C) the link (or part of it), then press cmd-Y (by default it's assigned to "create new note", I don't use notes)

  1. From Automator, I created a new service. Options: "no input", "any application"
  2. I selected "Run shell script'
  3. Added the following code to the script f="$(pbpaste | sed -e 's/N:/\/Volumes/g' | sed -e 's/\/\//g')" open "$f"
  4. Saved the service with a new name (ex. "openWinLinks")
  5. From System Preferences -> Keyboard -> Keyboard Shortcuts I assigned CMD-Y to run my script.

Done. :-)