running a script on an entire folder

28 views Asked by At

I am more familiar with R, and I haven't written scripts for a couple years due to a job change so any help would be greatly appreciated.

I have the following script that will list the feature datasets, feature classes, tables, raster's, data-type, shape-type, and then append it to a text file for a specified geodatabase. I would like to be able to apply this to an entire folder and have it run for all geodatabases in that folder. I feel like the WALK function is the way to go, but I am just not sure how to implement it.

import arcpy
import os

gdb = r'\\hanford\data\sitedata\LTS_GIS\HGIS\Data\data_4_temp_services.gdb'
textFile = r'\\hanford\data\sitedata\LTS_GIS\HGIS\Data\test2.txt'
f = open(textFile, "a")
arcpy.env.workspace = gdb

fcs = arcpy.ListFeatureClasses()
for fc in fcs:
fc_path = os.path.join(gdb, fc)
desc = arcpy.Describe(fc_path)
f.write(gdb + ","  + "NA" +","  + desc.dataType +","+ fc +"," + desc.shapeType + "\n")
    
fds = arcpy.ListDatasets("", "Feature")
for fd in fds:

fds_path = os.path.join(gdb, fd)
arcpy.env.workspace = fds_path

fcs = arcpy.ListFeatureClasses()
for fc in fcs:
fc_path = os.path.join(fds_path, fc)
desc = arcpy.Describe(fc_path)
f.write(gdb + "," + fd + ","+ desc.dataType +"," + fc + "," + desc.shapeType + "\n")

gdb = r'\\hanford\data\sitedata\LTS_GIS\HGIS\Data\data_4_temp_services.gdb'
textFile = r'\\hanford\data\sitedata\LTS_GIS\HGIS\Data\test2.txt'
f = open(textFile, "a")
arcpy.env.workspace = gdb

fts = arcpy.ListTables()
for ft in fts:
ft_path = os.path.join(gdb, ft)
desc = arcpy.Describe(ft_path)
f.write(gdb + "," + "NA" +"," + desc.dataType +"," + ft +"," + "\n")

gdb = r'\\hanford\data\sitedata\LTS_GIS\HGIS\Data\imagery.gdb'
textFile = r'\\hanford\data\sitedata\LTS_GIS\HGIS\Data\test2.txt'
f = open(textFile, "a")
arcpy.env.workspace = gdb

frs = arcpy.ListRasters("","")
for fs in frs:

fs_path = os.path.join(gdb, fs)
desc = arcpy.Describe(fs_path)
f.write(gdb + ","  + "NA" +"," + desc.dataType +"," + fs + "," + desc.format + "\n")
f.close()
0

There are 0 answers