I create sample packs and often need to process the samples to normalize, re-name, fix phase issues, etc. This script was created to automate this process. I've been using it for a few months now and it's been very helpful for my workflow, so figured I'd share.
Since we are only dealing with WAV files here, we just need one package - PyDub. Install it -I used a virtual environment for this project.
First, let's define some constants at the top
Next we can define a few functions to help rename things, if needed. I mainly did this because sometimes I mass-export clips from Ableton and the filenames have an insane string of numbers after each of them. I used the re library to try to detect all of this nonsense and delete it, while also being mindful of not overwriting existing filenames if they are no longer unique after cleanup.
I also added some logic to standardize the formatting of bpm, key, etc. if applicable.
Now get your wave file. I ended up using an Automator on Mac to run this script via an action in Finder (right click menu), but you can feed your files in however you wish.
Now do a bunch of checks / fixes:
Now save the file somewhere. I have the script create a folder in the wav directory, then save the files in there.
Note that I added some code to save a run file in the folder as well, mostly for debugging. You can delete all of this if ya want.
I don't expect this work super well as a copy+paste solution since most of the logic is customized to the issues I was running into, but hopefully it gives you ideas.