Skip to content

Instantly share code, notes, and snippets.

@bytrangle
Last active April 4, 2020 14:39
Show Gist options
  • Save bytrangle/0dd713f5ef697862b0e6593e2e3c7b02 to your computer and use it in GitHub Desktop.
Save bytrangle/0dd713f5ef697862b0e6593e2e3c7b02 to your computer and use it in GitHub Desktop.
This AppleScript will reveal the recently captured screenshots in the Finder. If the Finder is already active, it will bring the Finder to the frontmost, open a new tab, and navigate to the folder containing the screenshot.

To activate this script:

  • save the script to the folder users > your-username > Library > Workflows > Applications > Folder Actions
  • go to the folder that stores your screenshots. Right click to bring up the context menu.
  • select Servicess > Folder Action Setup.
  • select the script that you save in the first step.

The script will be triggered whenever there's a new item added to the screenshot folder, i.e, whenever you take a new screenshot.

If the Finder is already active, it will be raised to the frontmost, open a new tab, and navigate to the folder containing the screenshot. That way, you don't end up with dozens of Finder windows.

on adding folder items to theFolder after receiving theNewItems
-- Called after items have been added to a folder
-- theFolder is a reference to the modified folder
-- theNewItems is a list of references to the items added to the folder
tell application "System Events"
set activeApp to name of first application process whose frontmost is true
end tell
tell application "Finder"
# Bring the application to the front, launching if necessary
activate
tell application "System Events" to keystroke "t" using command down
set frontmost to true
set target of front Finder window to theFolder
reveal theNewItems
end tell
end adding folder items to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment