macOS FAQ: How can I get access to the full path of the current Mac Finder window? That is, when I’m looking at a Finder window that’s showing the contents of a directory like /Users/Al/foo/bar, how can I easily put that directory path on the macOS clipboard so I can use it in other applications?
Solution
I couldn’t find any way to do this through the Finder, so I wrote an AppleScript script to do it for me. Here’s my script that gets the current path from the Mac Finder and displays the path in a dialog so you can copy it to the MacOS clipboard:
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
One thing to note is that the Finder should be the foreground window when you run this script. (If it isn’t, you’ll see a wheel/sprocket menu item appear in the Mac menu bar, and the Finder icon will start jumping in the Dock. Just click the Finder icon in the Dock to make this behavior stop.)
You can send the path to the macOS clipboard without the use of a dialog, but even though it’s an extra step, I like the visual feedback. (It also helps in case you forget to have the Finder as your foreground window when you run the script.)
Access via the AppleScript menu
I set up my system so I can run this script from the AppleScript menu on the Mac menubar, like this:
If you haven’t done this before, I describe how to configure this AppleScript menu in the “Related” section below.
Running the script
When I run this script, this is an example of what the resulting dialog looks like:
At this point you can manually copy and paste the Finder path, or just press the Clipboard button to have the path sent to your MacOS clipboard.
Related
- If you don’t know where to save your AppleScript scripts (programs), see my tutorial, Where to save AppleScript programs so you can access them on the Mac/AppleScript menu bar
- If you don’t know how to show the AppleScript menu in the Mac OS X menu bar, see my tutorial, How to enable the AppleScript menu on the MacOS menu bar
In summary, if you were looking for an AppleScript script to get the current path from the MacOS Finder, I hope this is helpful.