Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Here is a handler I use to reveal in Finder the item currently selected in Path Finder. Often I need to do something in the Finder window, so I have added a pause until the Finder window name is the same as the Path Finder window name. Revised to Ve
on revealPFItemInFinder()
(* VER: 2.1 2018-03-19
PURPOSE: Reveal Item in Finder that is Selected in Path Finder
RETURNS: alias of item selected in both Finder and Path Finder
local finWinName, pfWinName, fileList, itemPath, oItem
tell application "Path Finder"
set fileList to (get selection)
if ((fileList is missing value) or ((count of fileList) 1)) then error ("You must select only ONE file in Path Finder.")
set oItem to item 1 of fileList
set itemPath to POSIX path of oItem
set pfWinName to name of container of oItem
end tell
set itemAlias to alias POSIX file itemPath
tell application "Finder"
activate -- to make sure reveal will be in frontmost window
reveal itemAlias
--- Now Wait for New Finder Window with Same Name as Path Finder ---
set finWinName to name of window 1
set maxWaitTime to 2.0
set delayTime to 0.1
set waitTime to 0
repeat while finWinName pfWinName
delay delayTime
set finWinName to name of window 1
set waitTime to waitTime + delayTime
if (waitTime > maxWaitTime) then error "Max wait time of " & maxWaitTime & " exceeded waiting for Finder Window of " & pfWinName
end repeat
end tell
return itemAlias
end revealPFItemInFinder

This comment has been minimized.

Copy link
Owner Author

commented Mar 20, 2018

Revised to Ver 2.1 on 2018-03-19 to fix bug in PF window name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.