Select to view content in your preferred language

Finding All Geodatabases Inside Main Folder and Subfolders

5466
11
07-23-2010 06:41 AM
JeremyKoontz
Emerging Contributor
Good morning everyone,

I am working on trying to figure out how to create a list of full-path geodatabases that are inside a user-given folder.  I would like it to be able to look down into any number of subfolders to find geodatabases ( I.E. if the main folder is "D:\Data\, I would like it to find a geodatabase that is located in "D:\Data\this\is\my\deep\subfolder\path\something.gdb" ).  I currently have it working to pick up all personal databases by using regular expression matching, but the file geodatabases are giving me a lot of trouble.  Here is the code that I have so far:

for root, dirname, filenames in os.walk ( folder ):
    for file in filenames:
        if ( re.match ( "([A-Za-z0-9_]*).gdb", file ) ):
            geodatabases.append ( os.path.join ( root, file ) )
        elif ( re.match ( "([A-Za-z0-9_]*).mdb", file ) ):
            geodatabases.append ( os.path.join ( root, file ) )


What its doing is that it will find all of the files that are in the file geodatabase folder (which are conveniently named *.gdbindex and such, which are caught by my regular expression) and put those in the list.  I just want it to be able to figure out that it is a file geodatabase and put the path of the geodatabase in the list.

Thank you for your time!

Jeremy
0 Kudos
11 Replies
ChrisSnyder
Honored Contributor
Maybe try looking for the standard PGDG tables inside the .mdb. For example, all PGDBs have a table called GDB_ReleaseInfo.
0 Kudos
LoganPugh
Frequent Contributor
Maybe try looking for the standard PGDG tables inside the .mdb. For example, all PGDBs have a table called GDB_ReleaseInfo.


Is there a way to do this without using a 3rd party OLEDB/Jet library? The arcgisscripting ListTables command doesn't list those tables.
0 Kudos