<?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: Python Novice Question - Get a list of files in a directory with particular exten in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458245#M15429</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've tweaked the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;dirlist=os.listdir("c:\\Arcwork")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mdblist=[]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for item in dirlist:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if item.endswith("mdb"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print item&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mdblist.append[item]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print mdblist&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;_____________________________&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But I get this error: do I need to import another module to use the "Append'?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: Blue; font-style: italic;"&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__&lt;BR /&gt;&amp;nbsp; File "C:\Arcwork\GetMasterMDBList.py", line 8, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mdblist.append[item]&lt;BR /&gt;TypeError: 'builtin_function_or_method' object is unsubscriptable&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Aug 2010 18:46:21 GMT</pubDate>
    <dc:creator>SheriNorton</dc:creator>
    <dc:date>2010-08-20T18:46:21Z</dc:date>
    <item>
      <title>Python Novice Question - Get a list of files in a directory with particular extension</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458241#M15425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to generate a list of all files in a directory with a *.MDB extension (personal geodatabases) in a Python script. Should I first split the path and filenames:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;dirname = "C:\Arcwork"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(filepath, filename) = os.path.split(dirname)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and then somehow split the filename into name and extension (how?!), or vice versa?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 14:32:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458241#M15425</guid>
      <dc:creator>SheriNorton</dc:creator>
      <dc:date>2010-08-20T14:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458242#M15426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
dirlist=os.listdir(r"C:\Arcwork")
mdblist=[]
for item in dirlist:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if item[-3:] in ['MDB','mdb']
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mdblist.append(item)
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;its kind of wordy and a bit brute-force but it works &lt;span class="lia-unicode-emoji" title=":face_with_tongue:"&gt;😛&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:24:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458242#M15426</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2021-12-11T20:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458243#M15427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks - tried this but validation returns a syntax error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 16:25:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458243#M15427</guid>
      <dc:creator>SheriNorton</dc:creator>
      <dc:date>2010-08-20T16:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458244#M15428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks - tried this but validation returns a syntax error.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MBldr's Iterate Files [ArcGIS10] with File Extension set to .mdb will do what you want. Connect the Collect Values ModelOnly Tool to the iterator's output to get the list. Note though at this time the list is not export-able or save-able.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Barbara Bicking&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;GeoprocessingTeam&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 17:16:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458244#M15428</guid>
      <dc:creator>BBicking1</dc:creator>
      <dc:date>2010-08-20T17:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458245#M15429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've tweaked the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;dirlist=os.listdir("c:\\Arcwork")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mdblist=[]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for item in dirlist:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if item.endswith("mdb"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print item&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mdblist.append[item]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;print mdblist&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;_____________________________&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But I get this error: do I need to import another module to use the "Append'?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: Blue; font-style: italic;"&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "C:\Python26\ArcGIS10.0\Lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exec codeObject in __main__.__dict__&lt;BR /&gt;&amp;nbsp; File "C:\Arcwork\GetMasterMDBList.py", line 8, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; mdblist.append[item]&lt;BR /&gt;TypeError: 'builtin_function_or_method' object is unsubscriptable&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 18:46:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458245#M15429</guid>
      <dc:creator>SheriNorton</dc:creator>
      <dc:date>2010-08-20T18:46:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458246#M15430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;append uses round brackets&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; a_list = []
&amp;gt;&amp;gt;&amp;gt; for i in [1,2,3,4]:
...&amp;nbsp; a_list.append(i)
...&amp;nbsp; 
&amp;gt;&amp;gt;&amp;gt; print a_list
[1, 2, 3, 4]
&amp;gt;&amp;gt;&amp;gt; 
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:24:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458246#M15430</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T20:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458247#M15431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You want to call a method. You call objects by using round brackets.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;clm42's snippet misses a `:` at the end of line 4.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please note that Python is case-sensitive. Your attempt will fail if a file is - for whatever reason - called .MDB, .mDb or .mDB.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = 'test.MDB'
&amp;gt;&amp;gt;&amp;gt; a.endswith('mdb')
False
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Therefore you need to "convert" your item variable to lower-case before testing for 'mdb'&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; a = 'test.MDB'
&amp;gt;&amp;gt;&amp;gt; a.lower()
'test.mdb'
&amp;gt;&amp;gt;&amp;gt; a.lower().endswith('mdb')
True
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;This adds up to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;dirlist=os.listdir("c:\\Arcwork")
mdblist=[]
for item in dirlist:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if item.lower().endswith("mdb"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print item
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mdblist.append(item)

print mdblist&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:24:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458247#M15431</guid>
      <dc:creator>KarlOrmer</dc:creator>
      <dc:date>2021-12-11T20:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458248#M15432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Presto!!! Thanks so much to you all. :o)&lt;/img&gt; I promise to be on the "giving" side down the road... Have a terrific weekend. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Sheri&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Aug 2010 19:55:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458248#M15432</guid>
      <dc:creator>SheriNorton</dc:creator>
      <dc:date>2010-08-20T19:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458249#M15433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Better late than never &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import glob
for mdb in glob.glob('c:\\Arcwork\\*.mdb'):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print mdb
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The above snippet will return *.mdb and *.MDB (and *.MdB etc.) on case-insensitive filesystems, such as Windows.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For maximum portability, use something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for mdb in glob.glob(os.path.join(searchdir,*.[mM][dD][bB]')):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print mdb
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:24:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458249#M15433</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2021-12-11T20:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458250#M15434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Neat - thanks Luke! Sounds like this should work for Windows as well as Unix platform? I'll give a shot this morning. It's good to see there's usually more than one way of "skinning the cat".&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Aug 2010 12:00:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458250#M15434</guid>
      <dc:creator>SheriNorton</dc:creator>
      <dc:date>2010-08-24T12:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458251#M15435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Both code snippets will work on Windows and unix/linux, but the top one will only return *.mdb (not *.MDB/*.MdB/etc...) on unix/linux as those OSs have case-sensitive file systems (generally speaking, as there are case-insensitive types of filesystems for linux and you can enable case-sensivity for certain Windows filesystems).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Aug 2010 00:21:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458251#M15435</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2010-08-25T00:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458252#M15436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There is also a new List at ArcGIS 10 called ListFiles, arcpy.ListFiles ("*.mdb").&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Aug 2010 00:39:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458252#M15436</guid>
      <dc:creator>TedCronin</dc:creator>
      <dc:date>2010-08-25T00:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458253#M15437</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;i like using:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;for root, dirs, files in os.walk(r'your root directory'):&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;that way you can access directories and files independently.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 20:26:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458253#M15437</guid>
      <dc:creator>DanielSmith</dc:creator>
      <dc:date>2010-10-21T20:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458254#M15438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here are two more ways to do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;personal_gdbs = [file for file in os.listdir('c:/Arcwork' if file.lower().endswith('.mdb')]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = 'c:/Arcwork'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;personal_gdbs = arcpy.ListWorkspaces('*.mdb')&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Oct 2010 21:43:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458254#M15438</guid>
      <dc:creator>NiklasNorrthon</dc:creator>
      <dc:date>2010-10-21T21:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458255#M15439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;BR /&gt; &lt;SPAN style="font-family:&amp;quot;Courier New&amp;quot;;"&gt;&lt;BR /&gt;import os&lt;BR /&gt;personal_gdbs = [file for file in os.listdir('c:/Arcwork') if file.lower().endswith('.mdb')]&lt;BR /&gt;&lt;/SPAN&gt; &lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To me, this looks like cleanest!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(I corrected a paranthesis in the snippet)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Oct 2010 10:26:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458255#M15439</guid>
      <dc:creator>HugoAhlenius</dc:creator>
      <dc:date>2010-10-29T10:26:21Z</dc:date>
    </item>
    <item>
      <title>Re: Python Novice Question - Get a list of files in a directory with particular exten</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458256#M15440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is a great thread.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Oct 2010 22:01:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/python-novice-question-get-a-list-of-files-in-a/m-p/458256#M15440</guid>
      <dc:creator>TedCronin</dc:creator>
      <dc:date>2010-10-29T22:01:29Z</dc:date>
    </item>
  </channel>
</rss>

