For many of my projects I use a single mxd to create multiple maps using a python script to switch on/off various raster layers before exporting to pdf. Before beginning the exporting process I currently have to open the legend properties window, go to the items tab, individually double click on each raster layer (often 50+ raster grids) and untick the "Show Layer Name" checkbox for each in order to display it correctly in the legend. As this is a highly manual process I almost always accidentally miss doing this for at least one raster in the list and have to spend time working out which layers to switch on/off before manually exporting.
Is there a way to automate removing the layer name line of each raster in the legend using python? i.e. leaving just the "Heading" and "Labels" boxes ticked.
Screenshot showing the location of the layer name I'm looking to remove and the tickbox to do so below. See red/yellow arrows.