Created
July 10, 2011 12:15
-
-
Save mmalecki/1074496 to your computer and use it in GitHub Desktop.
Simple Python script to remove leading numbers from file names (useful when renaming music files)
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
#!/usr/bin/python | |
import re | |
import os | |
import os.path | |
pattern = re.compile("^[0-9]+ ?- ?") | |
def directory(d): | |
for f in d[2]: | |
if pattern.match(f): | |
os.rename(os.path.join(d[0], f), | |
os.path.join(d[0], pattern.sub('', f))) | |
map(directory, os.walk('.')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If anyone has a tutorial of how to do this pls link me 🙏🏼. Really struggling so far to figure this out.