Home arrow GIS Data & Resources arrow Scripts and Code arrow Python arrow Python: Filename Search & Replace
Python: Filename Search & Replace PDF Print E-mail

Written by AGRC Administrator,


Simple python script to do a search and replace on filenames within a specific folder. import string
import os
dir = "C:\\files"
for f in  os.listdir(dir):
    filename = f
    filename = filename.replace("searchstring","replacestring")
    print f + " " + filename
    os.rename(dir + "\\" + f, dir + "\\" + filename)

Users' Comments  
 

Display 1 of 1 comments

1. Tue, 12-04-2007 at 05:43 PM

Thanks very much!

Display 1 of 1 comments

Add your comment

31, Oct. 2007
 
< Prev   Next >

AGRC Contacts | UGIC Contacts

feed image feed image

Utah GIS Portal © 2009 AGRC

Optimized for