Created
August 29, 2018 14:14
-
-
Save SavinaRoja/c1b739162b2dfbe45b0c5df529a32a2b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os | |
#Bandcamp filenames look like "<ARTIST> - <ALBUM> - ## TRACKNAME.flac" | |
old_names = [fn for fn in os.listdir('.') if os.path.splitext(fn)[1] == '.flac'] | |
new_names = [] | |
for name in old_names: | |
new_name = name.split(' - ', 2)[2] | |
int(new_name[:2]) # Will throw an error if this fails! | |
new_name = new_name[:2] + ' -' + new_name[2:] | |
new_names.append(new_name) | |
for old_name, new_name in zip(old_names, new_names): | |
os.rename(old_name, new_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment