"Everything is related to everything else, but near things are more related than distant things"
Copy Certain Feature Classes
The Python script reads all the feature classes in a personal or file geodatabase and copies only the polygon feature classes to a new file geodatabase.
# Ehsan Momeni
from arcpy import env, ListFeatureClasses, Describe, Exists, CreateFileGDB_management, CopyFeatures_management
from os import path
Input_path = r"C:\Users\emomeni\data"
Output_path = r"C:\Users\emomeni\output/"
env.workspace = Input_path # setting the environment for input path
env.overwriteOutput = True # setting the environment for overwrite
GDB = "New_Geodatabase.gdb"
if Exists(Output_path+GDB): # creating a new geodatabese
print ('\t%s is exist.\n' % GDB)
else:
CreateFileGDB_management(Output_path, GDB)
print ('\t%s is created.\n' % GDB)
for fc in fclist:
if Describe(fc).shapeType == "Polygon":
outFeatureClass = path.join(Output_path + GDB, fc.strip(".shp"))
CopyFeatures_management(fc, outFeatureClass)
print ("\t%s is copied successfully." % fc)