<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Issues with syncing metadata via Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/issues-with-syncing-metadata-via-python/m-p/1611235#M74120</link>
    <description>&lt;P&gt;I see an issue, Not sure if that is the main issue but you're calling fds_md.synchronize() instead of fc_md.synchronize().&lt;/P&gt;</description>
    <pubDate>Fri, 02 May 2025 18:53:29 GMT</pubDate>
    <dc:creator>TonyAlmeida</dc:creator>
    <dc:date>2025-05-02T18:53:29Z</dc:date>
    <item>
      <title>Issues with syncing metadata via Python</title>
      <link>https://community.esri.com/t5/python-questions/issues-with-syncing-metadata-via-python/m-p/1611165#M74117</link>
      <description>&lt;P&gt;I am having considerable frustration with updating metadata via scripting.&lt;/P&gt;&lt;P&gt;I have an enterprise geodatabase with many feature datasets. Inside each feature dataset are many feature classes. All feature datasets and feature classes have metadata, which I need to update.&lt;/P&gt;&lt;P&gt;There are 3 sources for my metadata (dynamically-defined items via scripting, synchronized properties, and a template) and I cannot get them to play nice with each other when it comes to displaying the extents of feature classes.&lt;/P&gt;&lt;P&gt;Dynamically-defined items include the fd / fc title, summary, description and tags. Synchronized properties are extents, feature classes, fields, crs, etc. The template contains the credits, contact information (a few times), and other information - stuff that doesn't change regardless of what feature dataset or feature class is being shown.&lt;/P&gt;&lt;P&gt;The most logical flow (in my head) is reflected in my current order of operations:&lt;BR /&gt;Import template&lt;BR /&gt;Update dynamically-defined items&lt;BR /&gt;Synchronize&lt;/P&gt;&lt;P&gt;With that flow, I've tried each of the metadata_sync_option choices; when using 'ALWAYS' everything syncs correctly for feature datasets, and everything syncs correctly &lt;EM&gt;EXCEPT&lt;/EM&gt; Extent for feature classes. How can I get the Extents of feature classes to be properly shown? When I click the Synchronize button everything is perfect, but I need to do this via scripting.&lt;/P&gt;&lt;P&gt;I've tried saving the metadata between steps, I've tried syncing before importing the template, after importing the template.... No joy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a minimal example of my code&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os
from arcpy import metadata as md

sde_connection = arcpy.GetParameterAsText(0)
metadata_template_path = arcpy.GetParameterAsText(1)
arcpy.env.workspace = sde_connection

fds_list = arcpy.ListDatasets(feature_type='Feature')

for fds in fds_list:
    fds_path = os.path.join(sde_connection, fds)
    fds_md = md.Metadata(fds_path)

    if not fds_md.isReadOnly:
        fds_md.importMetadata(metadata_template_path)
        # Here I add the metadata that is dynamically generated (title, summary, tags, etc)
        fds_md.synchronize(metadata_sync_option='ALWAYS')
        fds_md.save()
    else:
        arcpy.AddWarning(f"Metadata for {fds} is read-only")

    arcpy.env.workspace = fds_path
    fc_list = []
    fc_list = arcpy.ListFeatureClasses()
    
    for fc in fc_list:
        fc_path = os.path.join(sde_connection, fds, fc)
        fc_md = md.Metadata(fc_path)

        if not fc_md.isReadOnly:
            fc_md.importMetadata(metadata_template_path)
            # Here I add the metadata that is dynamically generated (title, summary, tags, etc)
            fds_md.synchronize(metadata_sync_option='ALWAYS')
            fc_md.save()
        else:
            arcpy.AddWarning(f"Metadata for {fds}\{fc} is read-only")

# reset workspace
arcpy.env.workspace = sde_connection&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 17:17:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issues-with-syncing-metadata-via-python/m-p/1611165#M74117</guid>
      <dc:creator>AlanDodson</dc:creator>
      <dc:date>2025-05-02T17:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with syncing metadata via Python</title>
      <link>https://community.esri.com/t5/python-questions/issues-with-syncing-metadata-via-python/m-p/1611223#M74118</link>
      <description>&lt;P&gt;is "reload" applicable to your situation?&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/metadata/metadata-class.htm" target="_blank"&gt;Metadata—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 18:14:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issues-with-syncing-metadata-via-python/m-p/1611223#M74118</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-05-02T18:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with syncing metadata via Python</title>
      <link>https://community.esri.com/t5/python-questions/issues-with-syncing-metadata-via-python/m-p/1611235#M74120</link>
      <description>&lt;P&gt;I see an issue, Not sure if that is the main issue but you're calling fds_md.synchronize() instead of fc_md.synchronize().&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 18:53:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issues-with-syncing-metadata-via-python/m-p/1611235#M74120</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-05-02T18:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: Issues with syncing metadata via Python</title>
      <link>https://community.esri.com/t5/python-questions/issues-with-syncing-metadata-via-python/m-p/1611252#M74121</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3265"&gt;@TonyAlmeida&lt;/a&gt;&amp;nbsp;I very much appreciate your keen eye in finding that. I was going crazy - it was a simple copy-paste when trying different options for the sync and I missed changing those two characters. Much appreciated, it solved this issue indeed. And I also provided a nice script if anyone wants to build it out for their needs &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; Future readers - change line 34 to be fc instead of fds&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 May 2025 19:39:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issues-with-syncing-metadata-via-python/m-p/1611252#M74121</guid>
      <dc:creator>AlanDodson</dc:creator>
      <dc:date>2025-05-02T19:39:06Z</dc:date>
    </item>
  </channel>
</rss>

