It is commonly asked how to get a Terminal prompt from a Finder window. I am asking the opposite.
I would like a command-line way of determining the working directory of the "current" Finder window.
findermacosterminal
It is commonly asked how to get a Terminal prompt from a Finder window. I am asking the opposite.
I would like a command-line way of determining the working directory of the "current" Finder window.
Best Answer
The following command will return the path to the frontmost Finder window, if that's what you're looking for:
Note that this cannot return a POSIX path if the frontmost window has no POSIX path. So if the frontmost Finder window has an ongoing/finished search, is a smart folder or other magical location (like your Mac under devices, which lists all the mounted volumes and the network).
Search/Smart folder/No Finder window returns:
And trying to execute the command when viewing your Mac: