Created
June 24, 2021 08:26
-
-
Save eupendra/0bd01166f983c18b3efb35ce16e8bf4c to your computer and use it in GitHub Desktop.
I wrote this to rename my mp3 files to remove unwanted text like junk, backup etc. Used `renames` instead of `rename` so that new directories can be created as well.
This file contains 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
strip_text=['junk','backup'] | |
for fn in glob.glob("**/*.mp3", recursive=True): | |
f=os.path.abspath(fn) | |
try: | |
for t in strip_text: | |
if t in f: | |
new_f=f.replace(t,"").strip() | |
os.renames(f, new_f) | |
f=new_f | |
except: | |
pass #ignore file in use etc | |
print('Done!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment