[GIS] Seeking tool/script to batch save multiple MXD files to map packages
arcgis-10.0arcmaparcpymap-package
I have a directory and sub-directory with many map documents (MXD). I need to save these MXDs to map packages to send to a client. This can be done through File/Create Map Package.
Are there any tools or scripts that will take all of these MXDs and produce map packages in batch mode, preferably in the background?
Find and create map packages for all map documents that reside in a
specified folder.
# Author: ESRI
# import system modules
import os
import arcpy
from arcpy import env
# Set environment settings
env.overwriteOutput = True
env.workspace = "C:/arcgis/ArcTutor/Editing"
# Loop through the workspace, find all the mxds and create a map package
using the same name as the mxd
for mxd in arcpy.ListFiles("*.mxd"):
print "Packaging " + mxd
arcpy.PackageMap_management(mxd, os.path.splitext(mxd)[0] + '.mpk', "PRESERVE",
"CONVERT_ARCSDE", "#", "ALL")
The .xml file is your metadata file. It is created whenever you save an .mxd because arcmap expects you to add metadata to all your ArcMap projects. It doesn't damage your .mxd to delete it; but really you should be adding metadata to all your maps anyway so you will only be re-creating it later on if you do delete the .xml
The "Blocks" features and "Coverage" features were not indexed alphabetically as anticipated. Thus the iteration selected feature classes that did not overlap as expected. Adding blockList.sort() and coverageList.sort() after defining each list made sure that the correct feature classes were selected in the for loop.
Best Answer
you can write your tool with Package Map (Data Management). and there is a very good example there to use.