AnsweredAssumed Answered

Find and replace text for all map documents within a folder (mxd)

Question asked by geonetadmin on Feb 21, 2012
Latest reply on Apr 8, 2013 by se2539
Original User: mthorpe


I'm looking to use a Python script to update the text on multiple mxds without opening each one up. Basically a find and replace function, looped through all MXDs in a directory. I have no real Python experience, so perhaps this has a simple answer. This is the code I have right now.

import arcpy, glob, os

path = r"C:\\"
mxdList = glob.glob(path + "\*.mxd")

for mxd in mxdList:
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
  if elm.text == "works":
   elm.text = "replaceword"
del mxd

The error I am receiving now is "Runtime error <type 'exceptions.AttributeError'>: 'str' object has no attribute '_arc_object'"