Script to change Zoom virtual background every day

Over the past few months, I found a new use of the pictures that I have clicked while hiking. I started using them as Zoom virtual backgrounds. If you are anything like me and take a lot of pictures, it can be hard to decide which one looks good. And then I decided to use them all, on different days. Sadly, Zoom does not have this as a built-in feature. And being a Software developer, I had to automate the process of choosing a random Zoom virtual background every day.

What does the script do?

Zoom does have an API that I could have used to change my background every day but that seemed like too much effort for this task. Software developers are born lazy, right?

- Advertisement -

Instead, I found out that the Zoom application creates a copy of the background that gets selected in its preferences folder and references it. The script just takes in a random file and replaces it with this background file. And voila! A different Zoom virtual background is shown. This can then be put in a cron job to be executed every day (or any frequency you prefer) to periodically change the background.


I have put all the images I want to use as backgrounds in a folder in my user directory. Mine is at /zoom/bgpictures/, and that is what I use in the script, but it is a variable that can be changed to whatever you want it to be.

Next, we set a Zoom virtual background in our application. It does not matter which one. All we need is the unique ID that Zoom will assign to this background. There might be some files already in the directory, but we want to select the one that corresponds to the image that we just uploaded to avoid replacing a different file. The directory is located at: ~/Library/Application Support/ The file name will be something like: 9WAE197F-90G2-4EL2-9M1F-AP784B4C2FAD

The script

We will be using a bash script to replace the image we just used. I will be putting this scrip in the zoom folder that I created for the background images. It can again be named whatever you like, I am naming mine as ~/zoom/ The script is as follows:


# The name of file that we copied before and will be replaced with

# Directory where Zoom keeps the backgrounds
ZOOM_DIR="/Users/$USER/Library/Application Support/";

# Directory of our images

# Picking a random file
NEW_BG=$(find "$BGPATH" -type f | sort -R | head -1);

# Replacing the file
cp -R "$NEW_BG" "$ZOOM_DIR/$OG_BG";

If you choose different paths for the directory, change it in the variable. We need to make this script executable by running the command:

chmod 755 ~/zoom/

Changing Zoom virtual background randomly

The script is ready. All we need to do is put it in a cron job which is a built-in time-based job scheduler. We need to decide a schedule for how frequently we want to change the Zoom virtual background. I do mine at 9:55 AM every day since my meetings start at 10 AM.

If you are new to cron jobs, you can use the generator to help you. I use:

55 9 * * 1-5 /Users/saranshkataria/zoom/ > /dev/null 2>&1

The first part (55 9 * * 1-5) is what you will need to customize according to your schedule. The second part is just telling the OS what to do at that point in time. The path will need to be updated if you chose a different location for the bash script.

To put it in a cron job, type

crontab -e

and it will open up an editor using vi. Hit the I key on the keyboard to enter insert mode, paste in the line, and press Escape followed by “:wq” and enter to save and quit.

That is all there is to it and we shall have a random Zoom virtual background every day/ frequency you chose!

If you are using Windows, the script can be modified accordingly and should be fairly straightforward to use.

If you have any questions, feel free to drop a comment below!

Recent Articles

How to sort a Set in JavaScript

ES6 introduced the set data structure in JavaScript. But sets are not ordered abstract data structures. So there is no .sort() property...

Debugging CSS scroll using one simple style

I have been doing a lot of complicated front-end work off lately and that always brings me back to the class conundrum...

CSS :has a parent selector now

CSS now includes a :has selector that allows us to apply styles on the basis of what is happening inside an element....

How to fix “invalid active developer path” after MacOS update

If you are here, then you are getting an "invalid active developer path" error on running commands in the terminal after a...

Getting the value of an input element as a number without parseInt

Every once in a while, you come across something and you think, how did I not know this earlier? valueAsNumber is that thing...

Related Stories

Leave A Reply

Please enter your comment!
Please enter your name here

Hi there! Want some more knowledge?

Think that the knowledge shared is helpful? You might want to give our mailing list a try. We'll send you 2-4 emails a month, right when new posts come out.

Hi there! Want some more knowledge?

Think that the knowledge shared is helpful? You might want to give our mailing list a try. We'll send you 2-4 emails a month, right when new posts come out.