Sorry for the misunderstanding. Here is an example on how to change the layer names:import arcpy, os
from arcpy import env
from arcpy import mapping
env.workspace = r"C:\temp\python"
env.overwriteOutput = True
for (path, dirs, files) in os.walk(env.workspace):
for file in files:
if ".mxd" in file.lower():
mxd = os.path.join(path, file)
mxd = mapping.MapDocument(mxd)
for df in mapping.ListDataFrames(mxd, "*"):
for lyr in mapping.ListLayers(mxd, "*", df):
if " " in lyr.name:
lyr.name = lyr.name.replace(" ", "")
for lyr in mapping.ListLayers(mxd, "*", df):
if "," in lyr.name:
lyr.name = lyr.name.replace(",", "")
mxd.save()
del mxd