I want to test:
- to see whether or not ONE AND ONLY ONE shapefile (which will be based on a filename wildcard) exists in a directory.
- Add these shapefiles to a list
- Use this list variable as an input to merge_managment function.
I already know how to walk through directories and pick out those filenames but not how to do the above.
I was thinking something like:
rootDir = "\homePath" featureinput1 = "path" newOnlyShpList =  for dirPath, dirNames, fileNames in os.walk(rootDir): for file in fileNames: if fnmatch.fnmatch(file, "*" + "2012" + "*" + ".shp")== True ##AND IF ONE SHAPEFILE EXISTS BY ITSELF IN DIRECTORY:## ##append to newOnlyShpList arcpy.Merge_managment([featureinput1, newOnlyShpList], "OutputHere") elif ##ignore if greater than one shapefile
All I know about is the arcpy .exists function but all that does is return a boolean on whether any shapefile exists. Maybe I need to check just for 1 .shp extension and it has nothing to do with arcpy?
Thanks for any help.