Select to view content in your preferred language

Automate the .saveACopy() ArcPy method to reduce MXD file size

4972
12
Jump to solution
08-31-2014 01:42 PM
CarlBeyerhelm
Frequent Contributor

I have a folder of 50+ MXDs that have been edited repeatedly, such that their file size has increased over the course of time.  Applying File - Save A Copy from ArcMap, or the mapDoc.saveACopy() method in the Python window will reduce the current MXD's file size...but only for the MXD that is currently open in ArcMap.  Applying the mapDoc.saveACopy() method to a long ArcPy list of MXDs does, indeed make a copy of the MXDs, but it does not also reduce their file size.

So, the question is, is there a way to automate MXD file size reduction?  I've explored the os.startfile(mxd_path) scenario, but it opens a new instance of ArcMap for each MXD...which is not satisfactory.

Advice or insights are welcome.  Thanks...

12 Replies
CarlBeyerhelm
Frequent Contributor

Yes, maintaining geoprocessing history can be one source of MXD bloat.  However, the most puzzling (and annoying) one is when you open an MXD, do nothing except click SAVE, exit ArcMap, and notice that the MXD has doubled in size.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

What's making the MXDs grow so much?  Good question, I wish we had clear answers.  Part of it is likely user behavior, although it is unclear what all behaviors cause the problem, but another part is how the MXDs are structured (design structure) and how ArcGIS interacts with them.  Geoprocessing history may play a part in some of the MXDs, but it isn't the dominant issue with the majority of the MXDs.

MXD bloat isn't an issue amongst GIS staff as much as the casual GIS user in our organization.  There are numerous worst practices that casual users seem to develop over time, and some of them may contribute to bloat, but there are limits to what can be expected from educating users on best practices.  The bottom line for us is that we have an issue, prevention has its limits, and so we need to explore ways of cleaning it up on the back end.

Opening up MXDs and trimming geoprocessing history will shrink some files to varying extents.  What also works is just opening up MXDs and saving a copy using the ArcMap UI.  The shortcoming of this approach is that it is manual.  We are looking for means to automate cleaning it up for thousands or tens of thousands of files.  Right now, either spawning docDefragmeter from Python or shell scripting it works, it is just clunkier and slower than we would like.

curtvprice
MVP Esteemed Contributor

That's great that DocDefragmenter.exe is working albeit being clunky. I'm going to vote up this thread!

0 Kudos