Tool stops executing if file not found

Discussion created by DezHoza on May 3, 2013
Latest reply on May 3, 2013 by DezHoza
Hello everyone. Iam relatively new to Python coding and have a simple question. I want to execute a tool, in this case, the Copy Features tool. I want this tool to copy files 1-16. The problem is not every file exists. For example, file 5 does not exist so the tool stops running.

for x in range (01,17):
...  arcpy.CopyFeatures_management("C:\\datafile" + "%02d" % (x,)", "C:\\GDB.gdb\\datafile" + "%02d" % (x,))

It copies files 01-04 but because 05 does not exist, the tool will abort the operation. How could I get it so if the file does not exist, the tool will copy the next file that does exist?