0

I have a file open in, say, a pdf viewer (or some other application). I want to get the path of the open file as text.

A simple approach to know the files location is to chose "Save As" - the dialogue comes up with the files current location selected. For pasting a path into such a dialogue, I can do cmd-shift-G, but the text box that appears contains the most recent path used this way (not the current files path).

Is there a way to access the path (as text) of a file open in an application?

  • Does it have to be from the Save As... dialogue? Can this be from the pdf viewer directly? Because I have an Apple Script solution to copy path to the file. – Mateusz Szlosek Apr 1 '16 at 10:03
  • From the viewer would also work, though I was hoping for a solution that would work in many contexts - for example, I use Skim for pdf's. Am I right in guessing that your script is application specific? – drevicko Apr 1 '16 at 11:14
  • Almost every file editor (document based app) has small icon on top of the title bar, you can use it as a file shortcut to retreive it's path. Apple Script in my answer. – Mateusz Szlosek Apr 1 '16 at 13:09
1

You can create small Apple Script and save it as an app.

on open {dropped_item}
    tell application "Finder" to set the clipboard to the POSIX path of the dropped_item
end open

Place this app on the Dock (easier to use). Then inside your pdf viewer you have small file icon on the top title bar -> drag it on top of the newly created app. With this, file path will be copied to the pasteboard.

enter image description here

  • Very nice! One question from a osx novice: how do I put it in the dock? I tried dragging it there, but it didn't stick.. It is saved as an Application (and it works :) – drevicko Apr 1 '16 at 13:34
  • Drag it to the dock and wait for a while (till the space for this icon appears). – Mateusz Szlosek Apr 1 '16 at 13:36
  • gr8 (: Only problem: dropping onto the dock icon isn't working, neither when the application is already running nor when it's yet to launch ): I selected "stay open" when I saved it, perhaps that's the reason? – drevicko Apr 1 '16 at 13:53
  • Probably that's the reason. I had this option not checked when saving the script. – Mateusz Szlosek Apr 1 '16 at 13:57
  • Yep, just remade the application and didn't check that item, now works well (: btw: doesn't seem possible to change that option once saved with it.. – drevicko Apr 1 '16 at 14:00

You must log in to answer this question.

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