I am trying to create a lyr file for each raster file in a folder. To get exact same display settings I thought I would create a lyr file, then, using arcpy copy-paste it for each file in folder and change the data sources.
The script generates new lyr files but does not change data sources - and gives no error. So, what am I doing wrong?
import arcpy lyrFile = arcpy.mapping.Layer(r"C:\temp\rst\sample.lyr") arcpy.env.workspace=r"C:\temp\rst" for i in arcpy.ListDatasets(): lyrFile.replaceDataSource(lyrFile.workspacePath,"RASTER_WORKSPACE",i) lyrFile.saveACopy(lyrFile.workspacePath+i)