If @ccstone’s macro works for you as it does for me (with projects in tabs), and if my Pages-specific script works for you in Pages (and similar), then my tip is to…
- use a proper AppleScript like my Pages example if the app is scriptable (Pages, Numbers and lots more)
- use Accessibility scripting (via
"AXDocument"
, ccstone’s script) if the app does not provide an AppleScript dictionary - try my Recent-Files approach in the (hopefully) rare cases where both of the above fail.
Thanks to KM it shouldn’t be a problem to have the right script executed when a specific app is frontmost.
But if you aim for an all-in-one script that works with most apps (without having to use specific scripts), then go the "AXDocument"
route (ccstone’s script).
IMO this is still preferable (by a comfortable margin) to taking a detour via PathFinder (or any other third app).
Unless you explicitly want to go via PathFinder. In this case it was me who misunderstood. (But then you should probably add “PathFinder” to the topic title…)
Just my tip.