<?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: List metadata with Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222918#M17206</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You were very close! I didn't handle any metadata on the feature dataset itself; you could add that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, sys
from xml.etree.ElementTree import ElementTree
from arcpy import env
env.overwriteOutput = True
env.workspace = r"D:\Lakeland_GIS\GDB\Lakeland\Lakeland.gdb\AddPoints"

AGSHOME = arcpy.GetInstallInfo("Desktop")["InstallDir"]
translatorpath = AGSHOME + r"Metadata\Translator\ARCGIS2FGDC.xml" 
xmlfile = r"U:\my docs\GIS Projects\Python\Scripts\List Metadata\working_test.xml" 
&amp;nbsp; 
# list any standalone feature classes
fcList = arcpy.ListFeatureClasses()
fcList.sort()
for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ExportMetadata_conversion(fc, translatorpath, xmlfile) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; tree = ElementTree() 
&amp;nbsp;&amp;nbsp;&amp;nbsp; tree.parse(xmlfile) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; spot = tree.find("idinfo/descript/purpose") 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print fc
&amp;nbsp;&amp;nbsp;&amp;nbsp; print spot.text
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# list feature datasets
datasetList = arcpy.ListDatasets()
datasetList.sort()
for dataset in datasetList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print dataset
&amp;nbsp;&amp;nbsp;&amp;nbsp; # list feature classes inside the dataset
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList = arcpy.ListFeatureClasses("","",dataset)
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList.sort()
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ExportMetadata_conversion(fc, translatorpath, xmlfile) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tree = ElementTree() 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tree.parse(xmlfile) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spot = tree.find("idinfo/descript/purpose") 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "&amp;nbsp; " + fc
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "&amp;nbsp; " + spot.text&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 10:50:30 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2021-12-11T10:50:30Z</dc:date>
    <item>
      <title>List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222901#M17189</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a list of feature classes from a geodatabase I created from a Python script and would like to add their respective metadata or a portion of (such as the description portion of the ArcGIS metadata style) to this list by feature class. Is this possible with Python or am I asking too much?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2011 20:00:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222901#M17189</guid>
      <dc:creator>JoshThompson</dc:creator>
      <dc:date>2011-06-20T20:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222902#M17190</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;I don't know how to get at metadata directly, but you can export the metadata to xml (I believe this tool only works FROM INSIDE PYTHON in SP1 and beyond) and then read through the xml with an ElementTree. I can't remember if the translator doesn't export all FGDC tags or doesn't import all FGDC tags correctly, but it's one of the two, so beware.&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, sys
from xml.etree.ElementTree import ElementTree
from xml.etree.ElementTree import Element, SubElement
from arcpy import env
env.overwriteOutput = True
fcpath = r"X:\working\metadata\BlankGDB.gdb\FullMetaFC" # the input feature class
translatorpath = r"D:\Program Files (x86)\ArcGIS\Desktop10.0\Metadata\Translator\ARCGIS2FGDC.xml" # the translator file to use - it should be in an installed folder like this
xmlfile = r"X:\working\metadata\FullMetaFC.xml" # the output xml file
arcpy.ExportMetadata_conversion(fcpath, translatorpath, xmlfile) # export the metadata to xml

tree = ElementTree() # make an ElementTree object
tree.parse(xmlfile) # read the xml into the ElementTree

spot = tree.find("idinfo/citation/citeinfo/title") # find whatever tag you want
print spot.text # print the text between the tags&lt;/PRE&gt;&lt;P&gt;edit: updated paths as Curtis advises below.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:50:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222902#M17190</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T10:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222903#M17191</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Danger, the code above uses normal strings with backslashes. These are escape characters in Python and will not work. Easily fixed by making them "raw" strings as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fcpath = r"X:\working\metadata\BlankGDB.gdb\FullMetaFC" 
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also you may want to read up on the Arc 10 metadata story, as both FGDC and ArcGIS 10 metadata may be in the metadata file and you will want to decide how you can handle that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A New Approach To Metadata at ArcGIS 10 (Part 1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://blogs.esri.com/Dev/blogs/arcgisdesktop/archive/2011/01/03/A-new-approach-for-Metadata-with-ArcGIS-10.aspx" rel="nofollow noopener noreferrer" target="_blank"&gt;http://blogs.esri.com/Dev/blogs/arcgisdesktop/archive/2011/01/03/A-new-approach-for-Metadata-with-ArcGIS-10.aspx&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:50:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222903#M17191</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T10:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222904#M17192</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oh, I can never remember which is which. It works fine as is, I suppose because there were no characters to be escaped...? In any case, you should probably fill in your own paths, as I doubt you have access to my X:/.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2011 21:23:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222904#M17192</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2011-06-20T21:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222905#M17193</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;It works fine as is, I suppose because there were no characters to be escaped...?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just don't ever name any folders or files starting with n, r, or t, etc....:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; "a\z" # "\z" is not a special string literal, so OK
'a\\z'
&amp;gt;&amp;gt;&amp;gt; "a\t"&amp;nbsp; # this is "a" followed by &amp;lt;tab&amp;gt;
'a\t'
&amp;gt;&amp;gt;&amp;gt; &lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;See:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://docs.python.org/reference/lexical_analysis.html#string-literals" rel="nofollow noopener noreferrer" target="_blank"&gt;http://docs.python.org/reference/lexical_analysis.html#string-literals&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:50:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222905#M17193</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T10:50:22Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222906#M17194</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey Guys,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the help. So far, all the info you have given me has worked very well. I am able to list the "Description" portion of the metadata for an individual feature class. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to integrate this code with the "Listfc" script? My ultimate goal is to list all feature classes, by dataset, and their respective metadata from a file GDB to give to staff in various dept. I am a beginner and am just not able to make this work on my own. I appreciate any help you can give.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jun 2011 17:37:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222906#M17194</guid>
      <dc:creator>JoshThompson</dc:creator>
      <dc:date>2011-06-21T17:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222907#M17195</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I am able to list the "Description" portion of the metadata for an individual feature class. &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cool! Please post your working script either in full or as an attachment. Wrapping this in a loop should be pretty straighforward.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jun 2011 18:38:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222907#M17195</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2011-06-21T18:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222908#M17196</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is the script I used (per dkwiens) to extract and print the "Description" portion of the metadata for an individual feature class:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy, sys&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from xml.etree.ElementTree import ElementTree&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from xml.etree.ElementTree import Element, SubElement&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.overwriteOutput = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fcpath = r"D:\GIS\GDB\Lakeland\Lakeland.gdb\AddPoints\AddressPts" # the input feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;translatorpath = r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Metadata\Translator\ARCGIS2FGDC.xml" # the translator file to use - it should be in an installed folder like this&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;xmlfile = r"D:\GIS\metadata\test.xml" # the output xml file&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.ExportMetadata_conversion(fcpath, translatorpath, xmlfile) # export the metadata to xml&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;tree = ElementTree() # make an ElementTree object&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;tree.parse(xmlfile) # read the xml into the ElementTree&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;spot = tree.find("idinfo/descript/abstract") # find whatever tag you want&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print spot.text # print the text between the tags&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you can help me tie this into the fcList script, I will be indebted to you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jun 2011 19:53:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222908#M17196</guid>
      <dc:creator>JoshThompson</dc:creator>
      <dc:date>2011-06-21T19:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222909#M17197</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Rather than call one feature class (fcpath), you'll call each feature class, one by one, from the fcList. This is totally untested, so you might run into errors (tricky areas might include overwriting the xml file, or reusing the ElementTree). You could also dynamically name the xml (e.g. with a similar name to the feature class name) inside the loop if you wanted separate xml files, rather than just one overwritten each time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, sys
from xml.etree.ElementTree import ElementTree
from arcpy import env
env.overwriteOutput = True
env.workspace = r"D:\GIS\GDB\Lakeland\Lakeland.gdb\AddPoints" # set the workspace for use in&amp;nbsp; ListFeatureClasses
fcList = arcpy.ListFeatureClasses() # lists all feature classes from inside env.workspace

translatorpath = r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Metadata\Translator\ARCGIS2FGDC.xml" # the translator file to use
xmlfile = r"D:\GIS\metadata\test.xml" # the output xml file

for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ExportMetadata_conversion(fc, translatorpath, xmlfile) # export the current fc's metadata to xml
&amp;nbsp;&amp;nbsp;&amp;nbsp; tree = ElementTree() # make an ElementTree object
&amp;nbsp;&amp;nbsp;&amp;nbsp; tree.parse(xmlfile) # read the xml into the ElementTree
&amp;nbsp;&amp;nbsp;&amp;nbsp; spot = tree.find("idinfo/descript/abstract") # find whatever tag you want
&amp;nbsp;&amp;nbsp;&amp;nbsp; print spot.text # print the text between the tags
 &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:50:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222909#M17197</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-11T10:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222910#M17198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried today to use the XSLTransform_conversion tool to just extract out everything (avoiding a transform) but I am getting an error message that appears to be a bug in tool validation (which I sent to ESRI support). I've attached this python script that is a function to pull out the ArcGIS metadata elements more directly (no need for the FGDC transform).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Arc 10 metadata schema is documented in the file:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;\ArcGIS\Desktop10.0\Metadata\Translator\Rules\ArcGIS metadata v1.dtd&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;though I have found it easier to just look in an existing ".shp.xml" file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another approach to this problem is to create an xslt stylesheet and run the XSL Transformation tool (conversion toolbox) to pull out the information&amp;nbsp; you want into an XML file.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jun 2011 22:25:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222910#M17198</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2011-06-21T22:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222911#M17199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I tried today to use the XSLTransform_conversion tool to just extract out everything (avoiding a transform) but I am getting an error message that appears to be a bug in tool validation (which I sent to ESRI support).&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe this was fixed in SP1. I can't remember the exact error I was getting, but it's gone now.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2011 04:40:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222911#M17199</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2011-06-22T04:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222912#M17200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Darren,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When I attempted to use the code you supplied, it simply moves to a new prompt. No errors, no output, nothing. Just a new prompt. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Curtis,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am getting the same error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Jun 2011 18:40:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222912#M17200</guid>
      <dc:creator>JoshThompson</dc:creator>
      <dc:date>2011-06-22T18:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222913#M17201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The following attached script works as a script tool. I get the error when I try to run it from IDLE or the command line... apparently there is something in the environment that is messing me up. I'm running 10.0 SP 2 on XP 64.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import sys, os, arcpy

def getMetadataText(Dataset,Element="dataIdInfo/idPurp"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; """Extracts metadata contents from ArcGIS metadata
&amp;nbsp; arguments
&amp;nbsp;&amp;nbsp;&amp;nbsp; Dataset - Path to an ArcGIS dataset
&amp;nbsp;&amp;nbsp;&amp;nbsp; Element - XML path in ArcGIS metadata. 
&amp;nbsp;&amp;nbsp;&amp;nbsp; Default: "metadata/dataIDInfo/idPurp" ("Summary")
"""
&amp;nbsp;&amp;nbsp;&amp;nbsp; from xml.etree.ElementTree import ElementTree
&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get arcgis to fgdc translator path
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARCGISHOME = arcpy.GetInstallInfo("desktop")["InstallDir"]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; XSLT = os.path.normpath(os.path.join(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ARCGISHOME,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Metadata/Stylesheets/gpTools/exact copy of.xslt"))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlTemp =&amp;nbsp; os.path.join(os.environ["TEMP"],"xx_xmltemp.xml")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # export the metadata to xml&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.env.overwriteOutput = True&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.XSLTransform_conversion(Dataset,XSLT,xmlTemp)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # parse out Description element from ArcGIS 10 metadata
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tree = ElementTree() # make an ElementTree object
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tree.parse(xmlTemp) # read the xml into the ElementTree
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Data = tree.find(Element) # find whatever tag you want
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del tree
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(xmlTemp)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Data.text # return the contents as text
&amp;nbsp;&amp;nbsp;&amp;nbsp; except Exception, xmsg:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise Exception, str(xmsg)

# You could put a loop here around this to print out Summary for a list of datasets
dataset = r"E:\work\work.gdb\BeetleSprayArea.shp"
text = getMetadataText(dataset)
arcpy.AddMessage(text)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:50:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222913#M17201</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T10:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222914#M17202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Curtis, but I'm afraid this code is beyond my skill level. I think I have gotten in over my head with this and need some more practice time with Python before trying this again. Thanks again for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Jun 2011 18:03:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222914#M17202</guid>
      <dc:creator>JoshThompson</dc:creator>
      <dc:date>2011-06-23T18:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222915#M17203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I brushed up on Python a little and attempted to tackle this script again. I have had some success in that I can now generate a list of feature classes and the "Summary" component of the metadata for all features &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;in a feature dataset&lt;/SPAN&gt;&lt;SPAN&gt;. The script below will produce that information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy, sys&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from xml.etree.ElementTree import ElementTree&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.overwriteOutput = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = r"D:\Lakeland_GIS\GDB\Lakeland\Lakeland.gdb\AddPoints"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;translatorpath = r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Metadata\Translator\ARCGIS2FGDC.xml" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;xmlfile = r"U:\my docs\GIS Projects\Python\Scripts\List Metadata\working_test.xml" &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;datasetList = arcpy.ListDatasets()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;datasetList.sort()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for dataset in datasetList:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print dataset&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fcList = arcpy.ListFeatureClasses()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fcList.sort()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for fc in fcList:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ExportMetadata_conversion(fc, translatorpath, xmlfile) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tree = ElementTree() &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tree.parse(xmlfile) &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; spot = tree.find("idinfo/descript/purpose") &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fc&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print spot.text &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I am attempting to do is generate a list of all feature classes, by dataset, &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;for an entire geodatabase&lt;/SPAN&gt;&lt;SPAN&gt;. Ex. - (Dataset&amp;gt;Feature Class&amp;gt;Metadata). As of now I can only get FeatureClass&amp;gt;Metadata for one feature dataset at a time.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Help! If anyone could help me complete this I would be truly appreciative.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 18:30:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222915#M17203</guid>
      <dc:creator>JoshThompson</dc:creator>
      <dc:date>2011-07-29T18:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222916#M17204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You really need to put these things in code blocks so we can see your loops.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;bbcode formatting: &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/misc.php?do=bbcode"&gt;http://forums.arcgis.com/misc.php?do=bbcode&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 19:27:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222916#M17204</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2011-07-29T19:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222917#M17205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry, Curtis. I didn't realize the format doesn't carry over into the message. Lesson learned. Sending the code as an attachment.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 20:03:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222917#M17205</guid>
      <dc:creator>JoshThompson</dc:creator>
      <dc:date>2011-07-29T20:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222918#M17206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You were very close! I didn't handle any metadata on the feature dataset itself; you could add that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, sys
from xml.etree.ElementTree import ElementTree
from arcpy import env
env.overwriteOutput = True
env.workspace = r"D:\Lakeland_GIS\GDB\Lakeland\Lakeland.gdb\AddPoints"

AGSHOME = arcpy.GetInstallInfo("Desktop")["InstallDir"]
translatorpath = AGSHOME + r"Metadata\Translator\ARCGIS2FGDC.xml" 
xmlfile = r"U:\my docs\GIS Projects\Python\Scripts\List Metadata\working_test.xml" 
&amp;nbsp; 
# list any standalone feature classes
fcList = arcpy.ListFeatureClasses()
fcList.sort()
for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ExportMetadata_conversion(fc, translatorpath, xmlfile) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; tree = ElementTree() 
&amp;nbsp;&amp;nbsp;&amp;nbsp; tree.parse(xmlfile) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; spot = tree.find("idinfo/descript/purpose") 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print fc
&amp;nbsp;&amp;nbsp;&amp;nbsp; print spot.text
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# list feature datasets
datasetList = arcpy.ListDatasets()
datasetList.sort()
for dataset in datasetList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print dataset
&amp;nbsp;&amp;nbsp;&amp;nbsp; # list feature classes inside the dataset
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList = arcpy.ListFeatureClasses("","",dataset)
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcList.sort()
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ExportMetadata_conversion(fc, translatorpath, xmlfile) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tree = ElementTree() 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tree.parse(xmlfile) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spot = tree.find("idinfo/descript/purpose") 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "&amp;nbsp; " + fc
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "&amp;nbsp; " + spot.text&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:50:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222918#M17206</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T10:50:30Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222919#M17207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Beautiful! That did it. Thanks Curtis for all your help and everyone else who contributed. Also, the indention to distinguish datasets from feature classes was a nice touch. Hadn't thought of that... &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Aug 2011 14:10:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222919#M17207</guid>
      <dc:creator>JoshThompson</dc:creator>
      <dc:date>2011-08-02T14:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: List metadata with Python</title>
      <link>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222920#M17208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just wanted to address two small issues with this script I have encountered:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First, the script works great in the Python window in ArcMap/ArcCatalog, but produces errors in Pythonwin: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(ExecuteError: Failed to execute. Parameters are not valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000816: The tool is not valid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (ExportMetadata).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Second, if the name of your feature class has the same name as the feature dataset it resides in, it will cause the script to fail. (ex. - Data.gbd&amp;gt;Contours&amp;gt;Contours) Will also terminate if no text is found in the metadata component it is looking for.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just wanted to let anyone who may use this script to be aware of these issues.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Aug 2011 18:49:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/list-metadata-with-python/m-p/222920#M17208</guid>
      <dc:creator>JoshThompson</dc:creator>
      <dc:date>2011-08-08T18:49:44Z</dc:date>
    </item>
  </channel>
</rss>

