I have the following code. I want to see if a layer name exists within a map document, not if the shapefile exists in the directory. If I copy paste into the python window within ArcMap works fine. IE. Prints: True
If I run the program as a stand-alone script it does not work? Prints False when should print True I have code the sets up the mxd and dataframe.
if arcpy.Exists("project_aoa") == True:
print("TRUE")
elif arcpy.Exists("project_aoa") == False:
print("FALSE")
These layers are withing a group layer should this matter?
project_aoa is a shapefile.
EDITED:
I ended up doing this:
for item in mxds:
mxd = arcpy.mapping.MapDocument(r"{0}".format(item))
df=arcpy.mapping.ListDataFrames(mxd,"Project Area")[0]
for lyr in arcpy.mapping.ListLayers(mxd, "project_aoa", df):
if lyr.name == "project_aoa":
print("True")
else:
print ("False")