I have ~200 layers in a Map Document, and I am trying to find the dates that these layers were created on (so I can export to database later). Some of these layers are housed in groups and sub-groups and also in gdbs, and I think this is creating a problem when I try to extract the metadata.
# import the modules. import arcpy import os import time # specify path of map document where layers are located. path = 'Location/1_STATEWIDE/' er = path + "Tool 10_2.mxd" # list layers using mapping module. I used this for earlier versions of the code where I had to extract layer longnames and datasources. mxd1 = arcpy.mapping.MapDocument(er) layers1 = arcpy.mapping.ListLayers(mxd1) # loop asks that for every layer in the Map Document, if the layer has a datasource, the os module will proceed to get creation time of the layer. The datasource condition exists so that group layers and sub-group layers will not give any results or errors; I just need times for the layers. for lyr in layers1: if lyr.supports("DATASOURCE"): sources = lyr.dataSource # need path to call time, so print list of paths before time commands. print os.path.getctime(sources)
This code gives the following error:
WindowsError: [Error 2] The system cannot find the file specified: u'\\\\Location\\Terrapins_horseshoecrabs\\2002terrapindata\\terrapin_survey2002.gdb\\beach_survey_2002'
So this must be because I am trying to find the creation time for the files in a geodatabase. How can I correct this code to avoid this error?