I few weeks ago I decided I wanted to learn some programming and started teaching myself python. For one of my first projects, I decided to write a backup script for my RawTherapee pp3 files. I wanted to solve 2 shortcomings with how RT manages its pp3s:
- There’s no way to save different edit snapshots in the pp3 itself
- Backwards-compatibility issues over different RT versions
The script starts in a folder and will recurse into all of its subfolders. It looks for .PP3 files in the directory and will make a “PP3 backups” directory if it finds them. It will then copy all the pp3 files into the backup directory, and append the RT version number and an incremental counter to the filename.
If you run the script again, it will examine all the PP3s it finds, and compare them to the pp3s inside the backup directory. If they are different, it will copy the newer version of the pp3 without changing the old one.
The idea is that you can experiment with different “looks” and not have to manually save & organize all the different pp3s.
There is a bug in my script that I cannot figure out. If anyone here is fluent in python, maybe they can tell me what the problem is?
I’m attaching the script and some example pp3s to this post. There are problems with the pp3s named “Will Coffin.jpg.pp3.” There is something about those files that when I run the script, they will always copy and overwrite the existing backups. The regex search at line 60 returns None when it should be finding a match in the backup directory. So far, all the other pp3s I’ve tested it on work fine.
You can test the script on other pp3s by opening one in a text editor, changing it somehow, and saving. The next time you run the script, it will detect the change and copy that version to the backup directory.
If you want to test the script, you’ll have to change line 13 to point to the path where your test pp3 files are. Right now, I would not feel safe pointing it at pp3 files that you care about.
I know there’s a lot of technical knowledge on these forums, so figured this would be a good place to ask.
Edit: I put the code on pastebin if anyone wants to glance at it but not download the zip file.
pp3 Backup Script.zip (184.1 KB)