Skip to content

Instantly share code, notes, and snippets.

@Junch
Created June 9, 2015 15:37
Show Gist options
  • Select an option

  • Save Junch/763b7e9be825e3d6e14a to your computer and use it in GitHub Desktop.

Select an option

Save Junch/763b7e9be825e3d6e14a to your computer and use it in GitHub Desktop.
Rename files in a directory
#!/usr/bin/python
import os, sys
import re
regex='^2015.+(\d\d.+)'
for file in os.listdir("."):
m = re.match(regex, file)
if m is not None:
print m.group(1)
os.rename(file, m.group(1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment