Select to view content in your preferred language

Adding all GIS Layers from a folder

2655
10
10-06-2011 08:17 AM
Ryan_Galbraith
Occasional Contributor
Anyone know how to create a looping statement that adds all the GIS layers from a folder?  Using arcpy.mapping.

Here is what I got:

arcpy.env.workspace = '#whatever the folder is'
mxd = arcpy.mapping.MapDocument("Current")
fclist = arcpy.ListFeatureClasses()
for fc in fclist:
     .....#something to add to your feature classes
0 Kudos
10 Replies
BenjaminGale
Occasional Contributor
Think this should work. I tested it on a folder of shp files.
arcpy.env.workspace = "WORKSPACE"
mxd = arcpy.mapping.MapDocument('CURRENT')
fclist = arcpy.ListFeatureClasses()
for fc in fclist:
    name = fc.split(".") #Splits the .shp from the name
    arcpy.MakeFeatureLayer_management(fc,name[0])
0 Kudos