I will answer this myself since I solved the problem. Short code to loop through current layers and get name of the gdb for all of them. If the source is the same for all layers each layer will show the same gdb. The dataSource printed below contains beside name of the gdb, also name of the layer. To extract just the name of the gdb you can use a method like: import os def getPath(source): # If there's a backslash, convert them to slash. Then you don't have to bother about backslash that also # work as a escape character. source = source.replace(os.sep, '/') s = source[:source.rfind(".gdb")+4] return s mxd = arcpy.mapping.MapDocument("CURRENT") for df in arcpy.mapping.ListLayers(mxd): if df.isFeatureLayer: print df.dataSource print df.datasetName gdbPath = getPath(df.dataSource) print gdbPath
... View more