I have a script that imports every MXD in a folder to an empty ArcGIS Pro project, then use saveACopy
to save to a new project file. The problem is: The script just stops working every several MXD. Nothing happens, no error thrown.
For debugging, I got 2 print statements, one immediately before, one immediately after importDocument
statement:
print(mxd_path)
aprx.importDocument(mxd_path)
print('imported')
Whenever the script reached a troublesome MXD, I got its path printed (the path looks totally normal to me), then nothing happened (have left it just like that for an hour). I've tried to import just that troublesome MXD with the script and got the same result: just the path printed, then nothing happened.
When I open the ArcGIS Pro app and import the manual way, i.e. right-click on the mxd file in Catalog pane and select Import and Open, the same troublesome MXD is imported and opened in seconds.
For MXD that can be imported via the script, it's done in less than one second.
MXD files are located in local hard drive. MXD file names contain A-Z character and dot. I've tried removing the dot from the file name of the troublesome MXD and that did not help.
The good news: When I opened the troublesome MXD in ArcMap application, saved it without doing anything, then re-run the script, that MXD was imported in less than one second. That means opening the MXD in ArcMap, then just save it will solve the issue.
The bad news: the way ArcPy opens and saves map Document is different from the way ArcMap application does. So using a script to open and save (or saveACopy
) does not solve the problem.