I would like to check in one geodatabase and list the feature classes that are in it; check another geodatabsae for the list of feature classes, if they do not exist in the 2nd geodatabase then execute feature class to feature class. If one does then just skip. How can this be done with Python? Here is what I have so far. After I get my list how can I use arcpy.Exists
to check another .gdb from my list, and if an element in the list does appear in that .gdb then skip it, however if it does not, then execute the function?
>>> import arcpy
... from arcpy import env
... import os
...
... # Set the workspace for the ListFeatureClass function
... #
... env.workspace = r'C:\GIS_Data\MXDs\ServerMxdsR\working\gis_dev01.gdb'
...
... # Use the ListFeatureClasses function to return a list of
... # shapefiles.
... #
... fcList = arcpy.ListFeatureClasses()
Best Answer
You want to try something like this
Loops through your feature classes from your
fcList
, checks if they exist in your second gdb, and if they don't it performsarcpy.FeatureClassToFeatureClass_conversion
to copy from gdb 1 to gdb 2.To only copy feature classes if none of them exist in gdb 2, try this:
This loops through all feature classes, and if it finds any already exist, then it sets the
anyFCExists
flag. Then if theanyFCExists
flag is not set then it loops through the feature classes and copies them all across.