This is the background:

in my company, we use Google Drive and often have to tell each other the path to a particular file. Paths are long as we use a lot of nested folders, so it's pretty boring and time consuming to browse through all that.

Now, in my previous company, we used a central afp server, so the path was common to everyone, therefore I had created an applescript script that could get the absolute afp path to the file, people pasted that path in a mail or chat and the end user could click on that path which automatically became a link and the finder would open, selecting that particular file or folder that the link led to.

The reason I can't use the exact same script is that Google Drive folder is in the user home folder. So if user's name is Foo the path will be file:///Users/Foo/Google Drive, while for user Bar the path will be file:///Users/Bar/Google Drive

Clearly the path generated from user Foo won't work for user Bar

Since, at least in the terminal, the path to file:///Users/username equals to ~, I made my script generate links like file:///~/Google Drive/pathToFolder, but they do not work :( Clicking on such a link will open the finder, but won't select the right file or folder

This is driving me crazy because it looks like it should work but it simply doesn't... is there any other syntax I should try? Any suggestion?

Thanks in advance!

  • Do you have access to the machines that will be opening these links?
    – 0942v8653
    Commented Feb 28, 2015 at 23:26
  • Yes i do, we're a small company, only 7 different machines Commented Mar 1, 2015 at 6:09
  • 1
    You could try LinCastor (I don't have time to write up an answer right now, but hopefully that helps a little)
    – 0942v8653
    Commented Mar 1, 2015 at 14:53
  • 1
    Exactly, that's what I have done and it worked like a charm :) Commented Mar 2, 2015 at 7:02
  • 1
    Great! Can you post it as an answer so other people can see what you did?
    – 0942v8653
    Commented Mar 2, 2015 at 19:57

1 Answer 1


Here is the solution. The script that generates the link, generats a url that starts with a custom googledrive:// and then the path to the file in the Google Drive folder.

I then set lincastor to trigger the following script for urls beginning with googledrive://

on handle_url(args)
    set theUnixPath to |URL_PATH| of args
    set theUnixPath to (POSIX path of (path to home folder)) & "Google Drive" & theUnixPath
    set theMacPath to (POSIX file theUnixPath)

    #display dialog "handle url: " & theMacPath 

    tell application "Finder"
        set theItem to item theMacPath
        if (class of theItem) is folder then activate
        reveal theItem
    end tell
    activate application "Finder"

    return 1
end handle_url

The script is super easy, it takes the url, attaches the path to the user homes folder and /Google Drive/, then uses this generated path to open the Finder and reveal the item

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .