I am trying to import network shapefiles to a local file GDB and I am having some trouble writing the script. The shapefiles have a consistent naming syntax as follows:
bob_[date as 8-digit YYYYMMDD]
I would also like to add a counter so that as each file transfers, the user will know how many have been transferred and how many are left to go. I had some ideas on it, but am interested to see how you all might solve that small addition.
Here is the sample script:
# Import system modules
import arcpy, sys, string, os, os.path
from arcpy import env
# Set environment / variables
sourceWorkspace = "C:/Users/jim/Documents/ArcGIS/bob_Shapefiles/"
env.workspace = "C:/Users/jim/Documents/ArcGIS/bob_Shapefiles"
targetWorkspace = "C:/Users/jim/Documents/ArcGIS/Park/bob_Original.gdb"
arcpy.env.overwriteOutput = True
dateBegin = 20000101
dateEnd = 20000103
shapes = arcpy.ListFeatureClasses()
# Loop to process each shapefile in sourceWorkspace
for shape in shapes:
dateName = shape[-8:]
# Set conditional statement to transfer only the desired date range.
if (dateName >= dateBegin) and (dateName <= dateEnd):
outFeature = shape
arcpy.FeatureClassToGeodatabase_conversion(outFeature, targetWorkspace)
print 'Transferring : ' + dateName
else:
print 'No files in date range to transfer.'
quit()