Tried this but I got the following error, not too sure what to do to fix this:Traceback (most recent call last): File "D:\Hugo\Scripting\Define Projection Script\Define_Projection_script_AVDAFIF_Test.py", line 28, in <module> DefineProjectionRecursive(root, datum); File "D:\Hugo\Scripting\Define Projection Script\Define_Projection_script_AVDAFIF_Test.py", line 24, in DefineProjectionRecursive for fc in fc_list:TypeError: 'geoprocessing list object' object is not iterableThanks anyways 😉
import os, fnmatch, arcgisscripting gp = arcgisscripting.create(9.3) rootDir = r"C:\temp" gdbList = [] for dirPath, dirNames, fileNames in os.walk(rootDir, topdown=False): if fnmatch.fnmatch(dirPath, "*.gdb") == True: gdbList.append(dirPath) gdbCount = len(gdbList) if gdbCount == 0: print "No matching FGDBs found!" else: print "Attempting to compress " + str(gdbCount) + " geodatabases..." for gdb in gdbList: try: gp.CompressFileGeodatabaseData_management(gdb) print "Compressed " + gdb + "..." except: print "ERROR: Failed to compress " + gdb + "!"
import os, fnmatch, arcgisscripting gp = arcgisscripting.create(9.3) rootDir = r"C:\temp" gdbList = [] for dirPath, dirNames, fileNames in os.walk(rootDir, topdown=False): for file in fileNames: if fnmatch.fnmatch(file, "*.mdb") == True: gdbList.append(dirPath + "\\" + file) gdbCount = len(gdbList) if gdbCount == 0: print "No matching PGDBs found!" else: print "Attempting to compact " + str(gdbCount) + " geodatabases..." for gdb in gdbList: try: gp.Compact_management(gdb) print "Compacted " + gdb + "..." except: print "ERROR: Failed to compact " + gdb + "!"
Untested, might need some debugging: import os def define_projection_recursive(root, spatial_ref): for path, subdirs, files in os.walk(root): gp.Workspace = path fc_list = gp.ListFeatureclasses() for fc in fc_list: gp.DefineProjection_management(fc, spatial_ref)
import os def define_projection_recursive(root, spatial_ref): for path, subdirs, files in os.walk(root): gp.Workspace = path fc_list = gp.ListFeatureclasses() for fc in fc_list: gp.DefineProjection_management(fc, spatial_ref)
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.