Last active
August 31, 2022 21:59
-
-
Save darwin/262db85585ea563f3060edb467dd2c95 to your computer and use it in GitHub Desktop.
This is a simple automation script to open a new Finder window with a pre-defined set of paths each in a new tab. Run it in `/Applications/Utilities/Script Editor.app` (hint: you can save the script as a standalone executable from there).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set paths to {"/Users/darwin/Music", "/Users/darwin/Desktop"} | |
-- initialize new Finder window | |
tell application "Finder" | |
activate | |
set finderWindow to make new Finder window | |
set toolbar visible of finderWindow to true | |
end tell | |
-- open all paths as new tabs | |
repeat with path in paths | |
set applePath to POSIX file path | |
tell application "System Events" | |
keystroke "t" using command down | |
end tell | |
tell application "Finder" | |
set target of finderWindow to applePath | |
end tell | |
end repeat | |
-- close the initial tab | |
tell application "Finder" | |
activate | |
tell application "System Events" | |
keystroke tab using control down | |
keystroke "w" using command down | |
end tell | |
end tell |
Can confirm script works when replacing 'open all paths as new tabs' section with darwin's link.
Tested on MacOS Catalina (10.15.6 19G73).
Thank you!
When running the line:
set target of finderWindow to applePath
The error
Script Error
Finder got an error: AppleEvent handler failed.
occurs.
I have tried my best to search this behavior, but I am still coming up short. Can you please assist? It would be much appreciated.
OS | Monterey 12.5.1
Script Editor 2.11 (227) (AppleScript 2.8)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try to look here: https://gist.github.com/darwin/05967eedcc377fdff843c3402e11dc69