As part of the onboarding at Culture Amp, I configure the dock at set a default wallpaper. This isn’t necessarily to lock down what Camper’s can do with their Macs but more-so to get them up and running as quickly as possible and in a consistent environment.

In the past I’ve simply installed a package that dropped an image into a folder and then run a postinstall script to set it as the wallpaper like so.

While this is an easy solution, I’ve recently been given a bunch more wallpapers that are currently being used throughout our meeting rooms and wanted to add some randomisation to what is being set on new Macs. After a but of Googling and BASHing my head against a wall I’ve come up with the following script. This script will look all files in a given folder and select one of them to set as the background. Feel free to use this as you see fit and let me know if you run into any issues

Enjoy!