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:temprstsample.lyr")
arcpy.env.workspace=r"C:temprst"
for i in arcpy.ListDatasets():
lyrFile.replaceDataSource(lyrFile.workspacePath,"RASTER_WORKSPACE",i)
lyrFile.saveACopy(lyrFile.workspacePath+i)