In order to set names from a text list to wav files in Python, you can use the os
module and regular expressions (regex
). By following the steps outlined below, you can rename your audio files based on the names in the text file.
main.py20 chars3 lines
main.py67 chars3 lines
os
module to access the directory with the wav files and loop over the filesmain.py110 chars4 lines
main.py45 chars2 lines
os.rename()
to set the new name of the wav filemain.py50 chars2 lines
Putting it all together, here's the full code:
main.py286 chars11 lines
Make sure to replace /path/to/audio/files
with the actual path to your directory containing the wav files, and list.txt
with the name of the text file containing the new names.
gistlibby LogSnag