How to populate metadata title from alias name of feature class?

01-02-2018 08:02 AM
Occasional Contributor II

I have a SDE with a lot of feature classes. I want to populate the metadata of the feature classes mostly automatic. Can I update the metadata title of all feature classes by using the alias name of the feature class? I have used the geoprocessing tool "Synchronize Metadata", it is useful for bounding box, spatial reference, etc. but it wont update the metadata title.

Tags (1)
2 Replies
MVP Esteemed Contributor

I'm fairly certain this would require some scripting to edit the metadata record, either using the metadata toolkit or exporting to XML and and editing with python tools and re-importing. Would really like to see some arcpy functionality to edit the main item/description components easily! Please vote the idea up!

Occasional Contributor II

So I made a python script for automatic updates of all feature classes in a geodatabase (also in feature datasets), my be this is helpful to others.

import arcpy
import codecs
import os
import xml.dom.minidom

workspace = r'C:\data\geodatabase.gdb' # or path to sde-file
temporaryXmlFile = r'C:\temp\xmlMetadataTransferFile.xml'

def getAlias(featureClass):
    return arcpy.Describe(featureClass).aliasName

def createTemporaryXmlMetadataFile():
    with open(temporaryXmlFile, 'w') as theFile:
        theFile.write('<metadata />')

def writeAliasToTemporaryXmlMetadataFile(alias):
    xmlFile = open(temporaryXmlFile)
    dom = xml.dom.minidom.parse(xmlFile)
    titles = dom.getElementsByTagName("resTitle")
    for title in titles: = alias
        title.setAttribute('Sync', 'FALSE')
        with, 'w', 'utf-8') as file2:
def doUpdate(path):
    arcpy.env.workspace = path
    fcList = arcpy.ListFeatureClasses()
    if fcList is None:
        print '- WARN: No feature classes found'
    for fc in fcList:
        print '- Feature class: ' + fc
        alias = getAlias(fc)
        print '  Alias: ' + alias
        arcpy.SynchronizeMetadata_conversion(fc, "ALWAYS")
        arcpy.MetadataImporter_conversion(fc, temporaryXmlFile)
        arcpy.MetadataImporter_conversion(temporaryXmlFile, fc)
        arcpy.SynchronizeMetadata_conversion(fc, "ALWAYS")

print 'Set resource title to alias name of all feature classes'
fdsList = arcpy.ListDatasets("*", "Feature")
if fdsList is None:
    print '- WARN: No feature datasets found'
    for fds in fdsList:
        print 'Feature dataset: ' + fds
        path = os.path.join(workspace, fds)
print 'done.'