I’ve written some basic code which creates a new .dbf and adds two fields to it: 1 for today’s date, another which should contain the names of shapefiles located in another folder. What I’d like to do is then write the names of the shapefiles to the newly created .dbf.
env.workspace = r'shapefile folder'
AT = r'location of new .dbf'
appendField = "ProjName"
dateField = "DateProc"
arcpy.AddField_management(AT, appendField, "TEXT")
arcpy.AddField_management(AT, dateField, "DATE")
shpList = arcpy.ListFeatureClasses()
for shp in shpList:
print shp
appendExpression = '"'+str(shp).replace('.shp','')+ '"'
arcpy.CalculateField_management(AT, "ProjName",appendExpression, "PYTHON")
arcpy.CalculateField_management(AT, dateField, 'time.strftime("%d/%m/%Y)', "PYTHON" )
I believe my issue is a result of having the table and feature classes in two separate workspaces. I am using 10.1. Thanks for any tips which may get this working.