Hello,
I am working on a script that will allow the user to create a list of feature classes, in a directory, where the wildcard is set by a user input argument (sys.argv[2]). But, I cannot figure out how to get the argument into the optional parameters (between the two asterisks). Here is the code that I am working on:
import arcpy, os
arcpy.env.workspace = sys.argv[1]
arcpy.env.overwriteOutput = True
sub = sys.argv[2]
fileList = arcpy.ListFeatureClasses('**')
Edited because I just figured out how to insert code.
Thanks,
Bill
Solved! Go to Solution.
Assuming sub is a string already:
fileList = arcpy.ListFeatureClasses('*' + sub + '*')
or
fileList = arcpy.ListFeatureClasses('*{}*'.format(sub))
Assuming sub is a string already:
fileList = arcpy.ListFeatureClasses('*' + sub + '*')
or
fileList = arcpy.ListFeatureClasses('*{}*'.format(sub))
Joshua,
Thanks so much that worked perfectly, I had tried the format, but had it located incorrectly.
This was how I had tried it -
fileList = arcpy.ListFeatureClasses('*{0}*').format(sub)
Thank you!!! Could not figure out how to do this.