I am trying to convert several shapefiles (in folder G:\desktop\Project\lyr) into layer files using this python code:
import arcpy,os from arcpy import env env.workspace = r"G:\desktop\Project\lyr" env.overwriteOutput = True for files in arcpy.ListFeatureClasses(): filesPath = arcpy.Describe(files).catalogPath arcpy.MakeFeatureLayer_management( filesPath,"lyrName") arcpy.SaveToLayerFile_management("lyrName",os.path.splitext(filesPath) + ".lyr")
the code work fine, and all the shapefiles converted into layer files with the same name of the shapefiles:
But when I load those layers files into the MXD file, all the layers have the same name, whereas I expected each layer will have a specific name:
I really don't understand what am I doing wrong.