I have a script for traversing a directory tree and finding shapefiles with a particular name. The issue I'm having is that the shapefiles are named improperly for databasing i.e. 20160527_Whatever.shp (total of 24 characters). The script is supposed to remove the date from the beginning, and add it to the end for the filename. Currently it outputs the same filename over and over again and fails. Snippet of the portion failing below (haven't done a lot of string parsing)
import arcpy, os, fnmatch from arcpy import env env.overwriteOutput=True rootDir = "whatever directory" search = "whatever criteria" outGDB = "whatever GDB" shpLst =  for root, dirs., files in os.walk(rootDir, topdown=True): for filename in fnmatch.filter(files, search): shpLst.append(os.path.join(root, filename)) for fc in shpLst: outName= (os.path.basename(shpLst[-30:-4]) + "_" + os.path.basename(shpLst[9:-31])) arpy.FeatureClassToFeatureClass_management(fc, outGDB, outName, "", "", "") print outName + " sent to " + outGDB
As I said, the above outputs the same exact file name every time, so I'm guessing it's a problem with the way I'm parsing the string?