<?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: Wildcards? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/wildcards/m-p/269177#M20736</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks so much Logan.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 23 May 2011 18:23:06 GMT</pubDate>
    <dc:creator>PaulBoehnlein</dc:creator>
    <dc:date>2011-05-23T18:23:06Z</dc:date>
    <item>
      <title>Wildcards?</title>
      <link>https://community.esri.com/t5/python-questions/wildcards/m-p/269171#M20730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a group of raster datasets, some .Tiff's, some .jpg's.&amp;nbsp; I want to perform arcpy.ImportMetadata_conversion on them.&amp;nbsp; I recall doing something similar in Windows command line using something like...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;FOR %f in (*.tif) DO arcpy.ImportMetadata_conversion(example.xml, *.tif)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think that's called a wildcard?&amp;nbsp; Is there something equivalent I can do in Python?&amp;nbsp; Could someone show me an example?&amp;nbsp; Please forgive my newbieness.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 May 2011 13:53:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/wildcards/m-p/269171#M20730</guid>
      <dc:creator>PaulBoehnlein</dc:creator>
      <dc:date>2011-05-23T13:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcards?</title>
      <link>https://community.esri.com/t5/python-questions/wildcards/m-p/269172#M20731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can use glob.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import glob
import os

directory = r"c:\tiffs\"

for tif in glob.glob(os.path.join("*.tif")):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ImportMetadata_conversion("example.xml", tif)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:10:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/wildcards/m-p/269172#M20731</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-11T13:10:31Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcards?</title>
      <link>https://community.esri.com/t5/python-questions/wildcards/m-p/269173#M20732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jason,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the reply. Your directory path has a slash at the end; that gives me a syntax error in IDLE. When I remove the slash (see below), the script runs, but the metadata file does not get imported. Any thoughts?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import os, sys, traceback, string, arcpy, glob

try:

&amp;nbsp;&amp;nbsp;&amp;nbsp; directory = r"C:\Rectified Inundation Maps"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for tif in glob.glob(os.path.join("*.tif")):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ImportMetadata_conversion(r"C:\Rectified Inundation Maps\contact_PMI_maps.xml", tif)

&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Import finished."
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:10:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/wildcards/m-p/269173#M20732</guid>
      <dc:creator>PaulBoehnlein</dc:creator>
      <dc:date>2021-12-11T13:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcards?</title>
      <link>https://community.esri.com/t5/python-questions/wildcards/m-p/269174#M20733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oh, whoops. needs to be&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;directory = r"c:\tiffs\\"
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:10:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/wildcards/m-p/269174#M20733</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-11T13:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcards?</title>
      <link>https://community.esri.com/t5/python-questions/wildcards/m-p/269175#M20734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That corrects the syntax error, but it still doesn't work. Any other suggestions?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 May 2011 17:27:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/wildcards/m-p/269175#M20734</guid>
      <dc:creator>PaulBoehnlein</dc:creator>
      <dc:date>2011-05-23T17:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcards?</title>
      <link>https://community.esri.com/t5/python-questions/wildcards/m-p/269176#M20735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I think maybe Jason just forgot to use the directory variable in the os.path.join function. And you do not need trailing slashes when using os.path.join. This should work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import glob
import os

directory = r"c:\tiffs"

for tif in glob.glob(os.path.join(directory, "*.tif")):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.ImportMetadata_conversion("example.xml", tif)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you need a recursive function (goes into all subdirectories of the initial directory), take a look at some of these examples: &lt;/SPAN&gt;&lt;A href="http://stackoverflow.com/questions/2186525/use-a-glob-to-find-files-recursively-in-python" rel="nofollow noopener noreferrer" target="_blank"&gt;http://stackoverflow.com/questions/2186525/use-a-glob-to-find-files-recursively-in-python&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:10:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/wildcards/m-p/269176#M20735</guid>
      <dc:creator>LoganPugh</dc:creator>
      <dc:date>2021-12-11T13:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcards?</title>
      <link>https://community.esri.com/t5/python-questions/wildcards/m-p/269177#M20736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks so much Logan.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 May 2011 18:23:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/wildcards/m-p/269177#M20736</guid>
      <dc:creator>PaulBoehnlein</dc:creator>
      <dc:date>2011-05-23T18:23:06Z</dc:date>
    </item>
  </channel>
</rss>

