


This script will change the current desktop, then switch to the next desktop (on the right). Create AppleScriptĬreate a file called change_desktop.scpt: on run picture_file Time for another approach! One-time SolutionĪfter some research and trail-and-error, I came up with a solution. So iteration and indexing through MacOS desktops in AppleScript is broken. I tried tell desktop 2 but that always fails even though I have 3 desktops. It only finds a single desktop, 1, regardless of which desktop you are on. This also fails to iterate through the desktops. Set picture to "/Library/Desktop Pictures/Beach.jpg" Repeat with desktopNumber from 1 to desktopCount So I tried another Stack Exchange answer using indexing 5: tell application "System Events" You can verify this by just adding a log "here" after set picture.Īt this point I wondered, is it just the “tell every” iterator broken? Maybe I can iterate the desktops by index. After some fiddling I confirmed that the “tell every desktop” block only ran once. When I ran this, it only set the current desktop image, and no others. Here is the AppleScript solution from Stack Exchange Apple: tell application "System Events" I don’t like deleting and recreating my desktops, so I decided to debug and fix the AppleScript solution. New desktops created always share Desktop 1’s wallpaper.” 4Īll but the last solution do not work any more.

In MacOS Big Sur 11.3, it has now gotten harder to update the desktop background for all MacOS desktops in one operation. If you just want the solution, it’s at the very bottom of this article.
