Listing feature classes in multiple geodatabases in folder using ArcPy?

The trick you're missing is making each gdb the active workspace before listing the contents:

for item in workspaces:
    print item
    env.workspace = item
    fcs = arcpy.ListFeatureClasses()
    for fc in fcs:
        print '\t', fc

Also note that this will miss an feature classes inside feature datasets, see Listing all feature classes in File Geodatabase, including within feature datasets? to solve that.

More generally, if you use r you don't need to double backslash everything (makes for easier copy and paste from windows explorer address bar etc.): e.g. r'D:\output'


This script will deal with any existing feature datasets (at least in theory - I haven't tested it). Same general idea though, if there are feature datasets, you need to set your working directory to that dataset before listing the features within.

import arcpy

dir = r'D:\output'
arcpy.env.workspace = dir

gdbList = arcpy.ListWorkspaces('*','FileGDB')

for gdb in gdbList:
    arcpy.env.workspace = gdb               #--change working directory to each GDB in list
    datasetList = arcpy.ListDatasets('*','Feature')     #--make a list of all (if any) feature datasets that exist in current GDB
    fcList = arcpy.ListFeatureClasses()         #--make a list of all feature in current GDB (root)
    for fc in fcList:
        print arcpy.env.workspace,fc            #--print directory,fc name
    for dataset in datasetList:
        arcpy.env.workspace = dataset   #--change working directory to each dataset (if any) in list
        fcList = arcpy.ListFeatureClasses()     #--make a list of all feature in current GDB (current dataset)
        for fc in fcList:
            print arcpy.env.workspace,fc        #--print directory,fc name
        arcpy.env.workspace = gdb