Search code examples
applescriptfinder

How to update/reveal in Finder using Applescript


Here is what I would like to do:

IF file is already present in a finder window
    tell finder to update...
ELSE
    tell finder to reveal...

Is there a way to determine if the file in question is already displayed in a current Finder window? I do not want to end up creating a duplicate.


Solution

  • The reveal command should already work that way. activate focuses Finder if another application is frontmost:

    tell application "Finder"
        reveal POSIX file "/usr/share/doc/bash/bash.html"
        activate
    end tell