Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. import os
  2. import re
  3.  
  4. dir = raw_input("Please enter the path you want to use: ")
  5.  
  6. for file in os.listdir(dir):
  7.     if not re.search(r'\d', file):
  8.         continue
  9.     newFilename = ''.join(re.split(r'\d', file)
  10.     os.rename(os.path.join(dir, file), os.path.join(dir, newFilename)
  11.     print "Renamed file %s to %s" % (file, newFilename)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement