Reputation: 1
I have a series of files that I need to add the creation year (2007) to the end of the filename:
Currently: NewZealand_cities.shp NewZealand_roads.shp etc.
Need: NewZealand_cities2007.shp NewZealand_roads2007.shp
I have been able to remove segments of text but cannot add for some reason. Any help would be much appreciated. Thanks.
Upvotes: 0
Views: 6527
Reputation: 7526
Did you try this:
import os
name, ext = os.path.splitext(fname)
os.rename(fname, name + '2007' + ext)
Upvotes: 3