Solved! Go to Solution.
import arcpy import os p = arcpy.GetParameterAsText(0) arcpy.env.workspace = p newtable = r"H:/TableList.gdb/GISLibrary" list = [] for dirpath, dirnames, filenames in arcpy.da.Walk(p): for filename in filenames: if arcpy.Exists(os.path.join(dirpath, filename)): arcpy.AddMessage("adding file to list") descr = arcpy.Describe(os.path.join(dirpath, filename)) list.append([descr.catalogPath, descr.name, descr.dataType]) else: arcpy.AddMessage('File ' + filename + 'does not exist') continue with arcpy.da.InsertCursor(newtable, ['Path', 'FileName', 'Type']) as insert: for f in list: insert.insertRow(f)
EDIT: this code only works when i chose a geodatabase as input p. if I used a folder (that contained geodatabases) as input all of my feature classes were tagged as "do not exist)
The code above actually did not work the next day....but this should be correct (although this code is now saying all tools don't exist, might be I need to use something different than arcpy.Exists(filename) or how I defined the environment/workspace or setting my parameter as a workspace but still working that out)
Tests for the existence of feature classes, tables, datasets, shapefiles, workspaces, layers, and files in the current workspace
import arcpy workspace = arcpy.env.workspace = r"U:" ## don't put the slash at the end..... workspace = arcpy.env.workspace = r"\\server1\U"
When topdown is True, the dirnames list can be modified in-place, and Walk() will only recurse into the subworkspaces whose names remain in dirnames. This can be used to limit the search, impose a specific order of visiting, or even to inform Walk() about directories the caller creates or renames before it resumes Walk() again. Modifying dirnames when topdown is False is ineffective, because in bottom-up mode the workspaces in dirnames are generated before dirpath itself is generated.
indatabase = "Database Connections\\Connection to RCES_P.sde\\SIS_ADM.IMAGES" # can use the database connection indatabase = "C:\\Users\\rkzufelt\\AppData\\Roaming\\ESRI\\Desktop10.1\\ArcCatalog\\Connection to RCES_P.sde\\ARCUPDATE.MAPS" #or the database connection file
Sure, I have done it a couple ways:
Assuming the networked computer is named "server1" and has a share named "U" and/or is mapped to drive U:import arcpy workspace = arcpy.env.workspace = r"U:" ## don't put the slash at the end..... workspace = arcpy.env.workspace = r"\\server1\U"
either works.
Keep in mind, though, setting it to the base level, by default, will drill down into all directories in there as well, so it can take a long time if there is much there. Better to set it to a working folder on the drive. Mine is still running as it is categorizing my entire drive.
R_
>>> import arcpy >>> import os >>> workspace = r"H:/LIBTest" >>> newtable = r"H:/TableList.gdb/GISLibrary" >>> list = [] >>> for dirpath, dirnames, filenames in arcpy.da.Walk(workspace): ... for filename in filenames: ... descr = arcpy.Describe(os.path.join(dirpath, filename)) ... list.append([descr.catalogPath, descr.name]) ... >>> with arcpy.da.InsertCursor(newtable, ['Path', 'FileName']) as insert: ... for f in list: ... insert.insertRow(f) ...