I need some help with os.walk and defining shapefiles in sub folders

Discussion created by streisel on Apr 10, 2013
Latest reply on Apr 10, 2013 by lpinner
So far this is what I have. It works if the shapefiles are in the C:/test_define folder, but it will fail with this error if they are in sub
folders. I am new to this so I am probably missing something simple, but I can't figure it out..

2000-10-Straight hole well.shp
Failed to execute. Parameters are not valid.
ERROR 000732: Input Dataset or Feature Class: Dataset 2000-10-Straight hole well.shp does not exist or is not supported
Failed to execute (DefineProjection).

My code
import os
import arcpy

# Set workspace environment to a folder
WS = "c:/test_define"
arcpy.env.workspace = WS

for (path, dirs, files) in os.walk(WS):
    for name in files:
        if name.endswith(".shp"):
            print name
            print ("-") * 50
                infc = name
                sr = arcpy.SpatialReference("NAD 1983 UTM Zone 11N")
                arcpy.DefineProjection_management(infc, sr)

                # print messages when the tool runs successfully
            except arcpy.ExecuteError:
            except Exception as ex: