Skip to content

Instantly share code, notes, and snippets.

@mmalecki
Created July 10, 2011 12:15
Show Gist options
  • Save mmalecki/1074496 to your computer and use it in GitHub Desktop.
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)
#!/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('.'))
@henners-other
Copy link

If anyone has a tutorial of how to do this pls link me 🙏🏼. Really struggling so far to figure this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment