I have a large number of files that begin with numbers (e.g., 10admin_boundary_x) and would like to rename the files so that they do not begin with a digit (e.g., admin_boundary_x). I am working with shapefiles (.shp, .shx, .dbf, etc) and thought a python script could save me some time.
I haven't quite figured it out yet, but here is the code I've got so far:
import os #read in file from the directory for filename in os.listdir("."): f = open(filename, "w") i = True while i: #if filename starts with a digit, lose first index by renaming and #try again while filename.isdigit(): filename = filename[1:] os.rename(f, filename) i = False print 'Any filename starting with a digit has been renamed.'
Thank you for your help!
Edited by csterling: n/a