Window Wonderland: Setting Up Project-Based Finder Spaces with AppleScript
Geek-o-meter: 1 2 3️⃣
Getting from mundane tasks, emails, and the general frenetic pace of everyday life into a state of hyperfocus that allows you to concentrate on the project at hand is an art form in itself. There are many booby traps and siren songs pulling you away from the task, making you feel like you're on an escape room-style hunt for the right clues.
Over the years, I’ve experimented with different tools to help me set up all the information I need to get started working. This involves gathering the correct notes from producers, reviewing the production table, organizing my project to-do list, but most importantly, setting up my Finder windows with the folders I need for the project.
Setup
When taking on a project, I use an automation that populates all my applications with project-related information. I hope to cover this in another post, but the summary is:
It creates a project folder hierarchy in my Dropbox.
It sets up To/From folders in a new project folder with my assistant.
It generates a project to-do list in my to-do application.
It organizes project notes in my notes application.
IIt schedules calendar blocks for the duration of the project.
…all based on the simple information I provide.
This means I end up with a bunch of folders and files that I know where to find and want to open, all following similar naming conventions.
I’ve found specific ways I prefer to open them. I like to have my working folder on the right half of the screen, the client folder in the top left quarter, and my assistant folder in the lower left. I also prefer Finder’s list view and, since I know where I am, I don’t need the sidebar.
Keyboard Maestro to the Rescue!
No, actually not. I did it with KM in the yesteryears. While it could easily locate the four folders I needed, occasionally it would end up placing two of them in the same spot. Views can be adjusted with a key command, but since my setup involved other elements, I often found that the key commands didn’t always target the correct windows. The sidebar is a toggle feature, so it's not possible to reliably set it to 'sidebar off' every time, as it will occasionally turn it back on.
Other apps like BetterSnapTool (or BetterTouchTool), Bunch (to a degree), or Moom can arrange windows, but none of them provide a perfect setup every time.
Introducing AppleScript
This is where I turned to a good old trusted scripting language. As I understand it, AppleScript has its quirks and is somewhat obsolete, but for controlling Finder, it has turned out to be rock solid.
AppleScript is a scripting language that uses plain English to control parameters. I picked up Sal Soghoian’s book on the topic and found some simple tricks in the first chapter to solve my puzzle.
You can write the scripts in Script Editor, which is native to the Mac, or in Keyboard Maestro. My preferred method is to write them in Script Editor to test them and then, once they work, transfer them to a Keyboard Maestro macro with the action ‘Execute an AppleScript’.
With AppleScript, I want to:
Close all windows
Open and position four different windows with specific folders, and I have preferences for how they look.
Let’s take a look at the script!
The Script
When you start writing in Script Editor, don’t worry about the fonts. It’s important that each line is on its own, and Script Editor will format it nicely once you compile.
First, I address Finder and ask it to close every window. Simple! Then, I have four commands, each starting with ‘open folder…’ and ending with ‘end tell.’ I hope this is easy enough to follow since the pattern repeats.
For each command, I:
Target the folder
Set the toolbar to visible
Set the status bar to invisible
Set the sidebar to invisible (by setting the width to 0)
Set the view to list view
Set the bounds
The bounds determine the position of the window. You’ll need to know your screen size for this. Go to System Preferences > Displays to find your monitor’s resolution. Mine is 3840x2160.
Each of the four numbers in the curly brackets represents a parameter of the window. They are {left, top, right, bottom}, measured from the top-left corner. So, if I want my project folder to be on the right half of the screen, I need to tell Finder to:
Place ‘left’ halfway from the top-left corner = 3840/2 = 1920
Place ‘top’ at the top of the screen = 0
Place ‘right’ at the far side of my monitor = 3840
Place ‘bottom’ at the bottom = 2160
The right side and the bottom represent the maximum number of pixels in the resolution away from the top-left corner.
It takes some tinkering to set it up initially, but after that, it’s just a matter of populating each project with the correct paths.
Tools
There are multiple ways to run an AppleScript. Both the native Shortcuts and Alfred can execute it. You can also trigger it from FastScripts as a menu item.
The window setup is part of a larger Keyboard Maestro macro for me, so I execute it via Keyboard Maestro as the first step before opening all my project-related documents. Start with whatever tools you have and see where it takes you!