Chances are that Lightroom backups have started filling your hard drive. This article shows you how to automate the deletion of older backups.
In this article you will learn to create a script which will identify and delete old Lightroom backups.
The script will allow you to define how many of your most recent catalog backups will remain on your hard drive. You can still restore your catalog in case it gets corrupted. The advantage is that your hard drive will no longer fill up with unused old catalog backups.
Cleaning up Lightroom catalog backups
To create the script file and adjust it to your needs, follow these simple steps:
Create the script file
- Copy the content of the script below and paste the code into Notepad or any other text editor of your choice
- Save the file with an extension of
.bat, for example
@echo off rem rem Adjust the folder below to match your environment pushd "%USERPROFILE%\Pictures\Lightroom\Backups" rem rem Adjust the 5 in skip=5 to the number of folders you would like to keep for /f "skip=5 delims=" %%a in ('dir /b /o-d /ad') do echo rd /s /q "%%a" popd rem Remove the next line if you don't want the script to pause before it ends pause
Adjust the script to your environment
There are two areas in the script that you need to adjust to your personal environment (marked in red):
- In line 4, after the
pushdcomment, you need to enter the path of your Lightroom catalog backups folder. The example in the script above will likely not work on your Personal Computer. You don’t know where your Lightroom backups are stored? In Lightroom, go to the catalog settings and set the backup frequency to “When Lightroom next exits”. Now exit Lightroom and look at the backup dialog that pops up:
You will find the backup folder location right below the Back up catalog frequency drop-down. Replace the red part of line 4 with your backup folder name, make sure you keep the double quotes.
- In line 7, replace the 5 in “
skip=5 delims=” with the number of recent backups you would like to keep. For example, if you would like to keep the 10 most recent backups, change it to: “
skip=10 delims=“. Again, make sure you keep the double quotes. Save the changes.
Test the script
Be aware that at this point, the script will actually not delete anything. It will just report which folders it would have deleted. We will use this to test if the script works correctly.
In Windows Explorer, double-click on the script file to execute it. You should see a window with content like this:
Your output will likely differ in the number of lines. The important thing here is to note which folders would have actually been deleted (the part in double quotes). You might have to scroll up to see the complete list. Now compare this list with the Explorer view of your Lightroom catalog backup folder. Ideally, the most recent folders you wanted to exclude do not show up in the output list.
After you have confirmed that the output matches your expectation, you can move to the next step. If you see an error message, please go back and check the script file for typos.
Remove the safeguards
Now that you are confident that the script will run correctly, it is time to remove the safeguards. For that, we need to remove the parts marked above in blue:
- In line 7, remove the word
do echo rd /s /q "%%a"at the end of the line so it reads
do rd /s /q "%%a".
- If you want, you can remove line 10 (the
pausecommand) completely. The script output window will close itself after it has completed. If you would rather verify what the script did, you can remove line 1 (the
@echo offcommand) instead. The output window will show you each step in detail.
This is it. Every time you want to delete old Lightroom backups, double-click the script file. I hope you find this article helpful, for sure it helped me to free up a lot of space on my hard drive. You can find additional helpful tips in the Photography How and Why section.
Automate the process
You can automate the process to delete old Lightroom backups. For that, use the Windows Task Scheduler to create a new job and run your script file for example weekly or monthly. Detailed instructions are currently not part of this post. But if you would like to know how to do this, please leave a comment below and I will update the article.
A simpler alternative: Lightroom Backup Cleaner plugin
You find the above solution too complex or use Lightroom for MacOS? You may want to check out the Lightroom Backup Cleaner plugin. It already supports Lightroom Classic CC, and you configure it from within Lightroom. It is not free, but available for a very reasonable amount.
Can you support this site?
Do you find this article helpful? To show your appreciation, why not buy me a coffee? ☕ No subscription. No further obligations. Just a quick and simple sign of gratitude. 🙏