0

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.

4

1 回答 1

2

你试过这个:

import os
name, ext = os.path.splitext(fname)
os.rename(fname, name + '2007' + ext)
于 2011-08-02T17:04:34.910 回答