Skip to content

Instantly share code, notes, and snippets.

@stdavis
Last active December 6, 2021 17:30
Show Gist options
  • Save stdavis/d163f2534f84ffe9f4fdad79e8fb64b2 to your computer and use it in GitHub Desktop.
Save stdavis/d163f2534f84ffe9f4fdad79e8fb64b2 to your computer and use it in GitHub Desktop.
import arcpy
import sys
AGRC = 'AGRC'
def get_tags_from_string(text):
if text is None:
return []
return [tag.strip() for tag in text.split(',')]
def fix_tags(table):
print(f'Checking: {table}')
metadata = arcpy.metadata.Metadata(table)
tags = get_tags_from_string(metadata.tags)
if AGRC in tags:
tags.remove(AGRC)
tags.append('UGRC')
old_tags = metadata.tags
metadata.tags = ', '.join(tags)
metadata.save()
print(f'---tags were updated from: {old_tags} to: {metadata.tags}')
workspace = sys.argv[1]
arcpy.env.workspace = workspace
tables = arcpy.ListTables() + arcpy.ListFeatureClasses()
for table in tables:
fix_tags(table)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment