一级文件夹下存在多个GDB,每个GDB存在多个要素类,要求对所有要素类重命名为:"GDB名_原数据名",如下图:
arcpy.env.workspace = "D:/.../一级文件夹"
wks = arcpy.ListWorkspaces(workspace_type="FileGDB")
for wk in wks:
arcpy.env.workspace = wk
fcs = arcpy.ListFeatureClasses()
for fc in fcs:
wkname = os.path.basename(wk)[:-4] # 去掉.gdb后缀
newname = "_".join([wkname, fc])
arcpy.Rename_management(in_data=fc, out_data=newname)