I've got a very simple script, that loops through all the layers in a mxd and loops through the fields, and prints out the Alias Name for the field, but I am having some problems, it seems to be printing the field alias of the feature class (in SDE) not the value I have changed it to in the map document...
Here's the script
import os, arcpy
myMxdFolder = r"D:\Maps"
count = 0
for mxd in os.listdir(myMxdFolder):
#print mxd
if mxd.endswith(".mxd"):
#if mxd.startswith("COMPASS") or mxd.startswith("COLGIS"):
if mxd.startswith("COLGIS_City_Occupiers.mxd"):
mxdoc = arcpy.mapping.MapDocument(myMxdFolder + os.sep + mxd)
filePath = mxdoc.filePath
print filePath
for lyr in arcpy.mapping.ListLayers(mxdoc):
desc = arcpy.Describe(lyr)
print lyr.name
fields = desc.fields
for field in fields:
print field.aliasName
The output is
OBJECTID
UPRN
ADDRESS
OCCUPIER
SHAPE
but the Aliases in the map document i have set it to are:
OBJECTID
HIGHLIGHT::UPRN
Address
Occupier
SHAPE
and that is what I was expecting, have a missed a trick somewhere in the code?