newName=''.join(''.join(oldName.split()).split(',')) #All of the quotes are single quotes
import os workspace = r"C:\temp\python" for (path, dirs, files) in os.walk(workspace): for file in files: if ".mxd" in file.lower(): if "," in file: str = os.path.join(path, file) new = str.replace(",", "") os.rename(str, new) elif " " in file: str = os.path.join(path, file) new = str.replace(" ", "") os.rename(str, new)
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
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.