BrokenLegMike

ImportMetadata_conversion using variables

Discussion created by BrokenLegMike on Jul 21, 2011
Latest reply on Jul 22, 2011 by BrokenLegMike
Hello,

I am trying to loop through a series of feature classes and a series of XML files. I want the loops to match up a feature class with it's associated XML document, and then import the XML into the feature class as metadata.

My script works up to the point that I want to import my metadata using "arcpy.ImportMetadata_conversion" All the print lines work fine and give me the result I am looking for, but I think when I plug some variables into the arcpy.ImportMetadata_conversion syntax, I get this error:


Failed to execute. Parameters are not valid.
ERROR 000816: The tool is not valid.
Failed to execute (ImportMetadata).


I looked up the error online and the solutions don't seem to fit my issue. Can anyone suggest what I may be missing?

    folderPath2 = r"Z:\Metadata\edited"
   
    # loop through folderpath2 and find all files with extension ".XML"
    for filename3 in glob.glob(os.path.join(folderPath2, "*.xml")):

        fullpath2 = os.path.join(folderPath2, filename3)

        # Split file name from full path name to isolate .XML file names
        if os.path.isfile(fullpath2):
            basename2, filename4 = os.path.split(fullpath2)
           #print filename4

            # List feature classes in workspace
            fcList = arcpy.ListFeatureClasses()
            
            # Loop through each deature class in workspace
            for fc in fcList:
                #print fc

                # if fc is equal a certain name and XML file name contains a certain string, then import the XML into the feature class for metadata
                if fc == "DEVELOPMENTAREA_R" and "DEVELOPMENTAREA" in filename3:
                    #print filename4
                    #print fc
                    #print "Match"

                    #this is where script crashes on import
                    arcpy.ImportMetadata_conversion(fc, "FROM_FGDC", shortname)

Outcomes