I have a number of .mxd files in a folder, in which i need to run certain operations. On one of them, specifically, when I try assigning it to a variable, I keep getting this error (and it's not the first of the lot):
Traceback (most recent call last):
File "<pyshell#29>", line 1, in <module>
mxd = arcpy.mapping.MapDocument(mxd_path)
File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\arcobjects\mixins.py", line 611, in __init__
assert (os.path.isfile(mxd) or (mxd.lower() == "current")), gp.getIDMessage(89004, "Invalid MXD filename")
AssertionError: Invalid MXD filename.
However, I'm pretty sure the name of the file is correct, and I can normally open it in ArcMap. Would anyone know what could be causing it? Here is the code I've been using to do it (fully functional for the others...):
import arcpy
import os
from os.path import join
mxdPath = "C://1331/DB/Original Files/MXD/"
for root, dirs, filenames in os.walk(mxdPath):
for f in filenames:
mxd_path = os.path.join(root, f)
mxd = arcpy.mapping.MapDocument(mxd_path) #This line returns the error for one specific file
#Some processing on the file: changing references, saving it as new file, etc;
del mxd
If it helps, the problematic file is called: "Figura 2.11 - Áreas Prioritárias.mxd". I've tried changing its name (other files have spaces and special characters, but the code runs without an issue for them), but it didn't help either. All the other files in the folder were made by the same person and in the same version of ArcGis, and are named alike. Eg: "Figura 2.10 - Unidades de Conservação", "Figura 2.13 - Densidade Demográfica", etc. The code works for these without an issue.