I am trying to copy a layer in an mxd and add that layer to the bottom of the TOC using Python, but I have not found a way to save the mxd programatically without making a copy. I also haven't found how to rename the copied layer. Here is my code: it runs with no errors but the copied layer is not added to the mxd when I open it.
import arcpy import arcpy.mapping mxd = arcpy.mapping.MapDocument(r"D:/arcgisserver/directories/my_mxd.mxd") df = arcpy.mapping.ListDataFrames(mxd, "Layers") print "df : " + df.name addLayer = arcpy.mapping.ListLayers(mxd, "", df) print "layer ? : " + addLayer.name arcpy.mapping.AddLayer(df, addLayer, "BOTTOM") # Refresh things arcpy.RefreshActiveView() arcpy.RefreshTOC() del mxd, df, addLayer