I have 250 maps (in separate MXD's). In each map, in the Layout view there is "aaa" text. the element name value is aaa.
I try to find a way to add serial numbers to each map, so each "aaa" text will converted to serial number. The result should be like that:
The serial number will start from 1 till 250.
I wonder if it possible to do it automatically, and not doing it manually?
I work on ArcGIS 10.3.1 with python 2.7.8 versions.
1 Answer 1
this code works perfect for me:
import arcpy
from arcpy import env
env.workspace = r"G:\desktop\Project"
counter = 0
for mxdname in arcpy.ListFiles("*.mxd"):
print mxdname
mxd = arcpy.mapping.MapDocument(r"G:\desktop\Project\\" + mxdname)
for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):
if elm.text == 'aaa':
counter = counter + 1
elm.text = 'serial num'+str(counter)
mxd.save()
del mxd