Mac AppleScript Finder - How to put the path of the current Finder window on the clipboard

Mac OS X FAQ: How can I get access to the full path of the current Finder window? That is, when I'm looking at a Finder window in a directory like /Users/Al/Foo/Bar, how can I easily put that directory path on the clipboard so I can use it in other applications?

As a Mac OS/X newbie I couldn't find a good way to do this, so I wrote an AppleScript (script) to do it for me. Here is the script:

tell application "Finder"
    set theWin to window 1
    set thePath to (POSIX path of (target of theWin as alias))
    display dialog thePath buttons {"Clipboard", "OK"} default button 2
    if the button returned of the result is "Clipboard" then
        set the clipboard to thePath
    end if
end tell

I set up my system so I can run this command from the AppleScript menu (menulet), and it works very well.

Post new comment

The content of this field is kept private and will not be shown publicly.