Copying files from one GDB to another with error reporting.

740
2
03-09-2014 06:44 PM
JohnEhlen
New Contributor II
I was hoping someone here could help me!

I'm trying to write a script that will allow me to transfer files from one GDB to another, excluding lines, and generate an error report in the process. In the arcpy module I've tried using ListFeatureClasses, Describe, and CopyFeatures but I haven't really been able to get anywhere. I'd appreciat if someone could point me in the right direction!
Tags (2)
0 Kudos
2 Replies
RDHarles
Occasional Contributor
Didn't have time to test it but something like this should work...

import arcpy

# Set input and output FGDBs
inFGDB = "in.gdb"
outFGDB = "out.gdb"


# Loop through inFGDB
arcpy.env.workspace = inFGDB
for fc in arcpy.arcpy.ListFeatureClasses():


    # Describe to get type
    dscFC = arcpy.Describe(fc)
    fcType = dscFC.shapeType
    print(fcType)


    # Don't get line fcs
    if not fcType == "Polyline":
        # Copy fc to outFGDB
        print("Copy "+inFGDB+"/"+fc+" to "+outFGDB+"/"+fc+" -- "+fcType+"\n")
        arcpy.Copy_management(inFGDB+"/"+fc, outFGDB+"/"+fc)
0 Kudos
MichaelVolz
Esteemed Contributor
Will you by any chance be using these file geodatabase feature classes as a data source for ArcGIS Server (AGS) pre10.1?  I ask because AGS  pre10.1 definitely put locks on the feature classes so you would get an error if you copied the feature class due to these locks.  If this is the case, you probably would need to perform truncate and append operations as that process bypasses AGS locks.
0 Kudos