Cycle Finder windows but exclude the desktop
My workflow often involves comparing two Finder windows side by side. I use shortcut 2 (see screenshot) to quickly cycle between the windows. However, the annoying thing is that the cycle also includes the desktop as a 'window'. Instead, I would just like to cycle between the two floating windows.
The closest I've come to achieve this is shortcut 1. This shortcut excludes the desktop, but unfortunately it will also cycle between the windows of all apps. It also doesn't work properly in Split View.
Is it possible to make shortcut 2 exclude the desktop? If not, is there another method to achieve what I want?
To be clear: I really want to exclude the desktop from the cycle because that enables me to use one shortcut to switch between the windows. I'm aware that you can go to the previous window using shift, but it's just way, way easier to go back and forth using the same shortcut.
Update 1: I just discovered that my question has been asked before: Command Tilde in Finder, prevent focus on Desktop at end of cycle. However, I don't think the answer there solves the problem.
Update 2: My solution.
Solution 1:
First, you're going to need an AppleScript that can swap the position of the two frontmost windows.
tell application "Finder"
set index of window 1 to 2
end tell
Now you need a way to make this script easily accessible from the Finder. We'll use macOS services, and Automator makes this super easy for us.
- Open Automator
- Make a New Document of type "Quick Action" (or "Service" in older macOS)
- Drag a new Run Applescript action into the workflow. You can find it in the Utilities category, or just search for it in the search bar.
- Copy the AppleScript shown above into the script box.
- Press ▶ to try it out. You'll get an error if you have fewer than two windows open -- I'll leave that as an exercise to the reader to fix.
- Save the workflow as
Swap Front Windows
. The moment you save it, it will become accessible from the Services menu under the application menu.
At this point you can really try it out. Go to the Finder and open two windows. Then go to the menu bar, choose Finder -> Services -> Swap Front Windows. It takes a moment, but it works. That's cool, now let's hook it up as a keyboard shortcut.
- Open System Preferences
- Go into Keyboard Preferences
- Go to the Shortcuts tab
- Go into the Services category
- Scroll down to the bottom. Underneath General you should see Swap Front Windows.
- Select the "Swap Front Windows" row, then click Add Shortcut.
- Enter the shortcut you want to use. I recommend Ctrl + Shift + `.