Hello,
I try to get the source of each "map layer".
Does anyone have an idea?
This is the beginning of code
import arcpy, os
path = "....."
for fileName in os.listdir (path):
fullPath = os.path.join (path, fileName)
if os.path.isfile (fullPath):
basename, extension = os.path.splitext (fullPath)
lyrname = arcpy.mapping.Layer (fullPath)
lyrlist = arcpy.mapping.ListLayers(lyrname)
print "Nom du Fichier: "
print fileName
print""
print "Nom de la couche : "
print lyrname
print""
print "Couches contenu: "
print lyrlist
print""
RESULT:
Nom du Fichier:
DTSI_aires_protegees_provinciales.lyr
Nom de la couche :
aires_protegees_provinciales
Couches contenu:
[<map group layer u'aires_protegees_provinciales'>, <map layer u'Aires prot\xe9g\xe9es provinciales marines'>, <map layer u'Aires prot\xe9g\xe9es provinciales terrestres'>]
Thank you
Untested, but I would try:
print lyrlist[0].dataSource
Or, loop through your list of layers, changing the index number, instead of [0].
This link Layer information in folders will give you a basis