bryan.deverot

Delete files in workspace that don't start with "f_"

Discussion created by bryan.deverot on Feb 2, 2012
Latest reply on Feb 2, 2012 by bryan.deverot
Hello

I want to delete files in workspace that don't start with "f_"

#loop through the directory
for root, dirs, files in os.walk(wksp):
for name in files:
if name[name.rfind("."):len(name)] == ".shp":
gp.workspace = wksp #set the current workspace
if name[name.rfind("."):len(name)] == ".shp":

Instead of finding a period and searching for 'shp' after the period, I would like to search for the start of files "_f"... something like. If it doesn't equal "_f", I want to delete those files.

if name[name.rstart] <> "f_":
gp.delete_management

I just made that up... Can someone give me a hand with this?

Outcomes