Starting with Mojave in 2018, macOS natively supports dynamic wallpapers. Here is a good article outlining how to rotate your custom wallpaper images with no scripting required. https://appleinsider.com/articles/18/10/01/how-to-create-your-own-dynamic-desktops-in-macos-mojave
Applescript for changing the Mac OS X desktop picture based on the time of day
This is an AppleScript that changes your Mac's desktop picture based on the time of day. The day is split into six 'periods':
Each period has a corresponding folder, which is meant to store images that evoke the period in question. For example, you could have a picture of a sunset in the "Evening Early" folder, or a picture of the moon in the "Evening Late" folder.
/Users/YOUR_USER_NAME/Pictures/Wallpapers/Time of Day/Evening Early/sunset.jpg /Users/YOUR_USER_NAME/Pictures/Wallpapers/Time of Day/Evening Late/moon.jpg
The script will randomly select an image from the corresponding folder. The image can be in any supported file type, including JPG, GIF and PNG images.
If you choose to use the default settings, all you need to do is create folders in your
Pictures folder that correspond to the following sample paths:
~/Pictures/Wallpapers/Time of Day/Morning Early/
~/Pictures/Wallpapers/Time of Day/Morning Late/
~/Pictures/Wallpapers/Time of Day/Afternoon Early/
~/Pictures/Wallpapers/Time of Day/Afternoon Late/
~/Pictures/Wallpapers/Time of Day/Evening Early/
~/Pictures/Wallpapers/Time of Day/Evening Late/
You must supply your own images. Personally, I downloaded images from NationalGeographic.com, which provides high quality free wallpaper images. http://ngm.nationalgeographic.com/wallpaper/download
This script file itself can be located anywhere. I keep mine in the
/Pictures/Wallpapers/Time of Day/ folder.
The script must be run at specified intervals using automation of some kind. I use GeekTool, but you may also use a built-in service such as crontab.
I instruct GeekTool to execute the script every 15 minutes (1800 seconds). Use this line in GeekTool's command field:
osascript ~/Pictures/Wallpapers/Time\ of\ Day/wallpaper.scpt
This script can be freely customized. It is heavily commented to make it easy to understand. For example, you can easily change the specified times of day or folder names by editing the script. You can simplify to something such as "day" and "night", or get even more granular and specify a custom folder for each hour of the day.
The script includes support for multiple monitors. By default, it will display the same image on all monitors. If you prefer to set a unique image on each monitor, set the
useSamePictureAcrossDisplays variable to