Here is a script I wrote, based on the example Package Map (Data Management).
It has a few changes you'd need to be aware of. It removes any rasters from the mxds and it sets the required Summary, Description & Tags to the name of the MXD. This will change your source files so be sure to back them up.
It also just looks into a single directory and creates a small CSV file detailing any errors with certain mxds.
To stop rasters from being removed comment out lines 54-58.
This script is ran from the windows command line with python <scriptname>.py
so you will need to ensure that the python.exe is included with ArcGIS is added to your system PATH. Most likely C:\Python27\ArcGIS10.2
# Import the required python modules
import arcpy
from arcpy import env
import os
import os.path
import glob
import string
import traceback
# Set some variables for the input MXDs
print 'Setting Paths'
path = raw_input('File Path to Folder Containing MXDs : ')
print path
mxdList = glob.glob(os.path.join(path, '*.mxd'))
print 'Paths Set'
env.workspace = path
arcpy.env.scratchWorkspace = path
env.overwriteOutput = True
arcpy.gp.overwriteOutput = True
outputcsv = path + "OutputLog_MXDs.csv"
outFile = open(outputcsv, "w")
outFile.write("MXD" + "," + "Status" + "," + "Error" + "\n")
successcount = 0
failcount = 0
# Module to set Descriptions, Summary and Tags for the mxd.
for filename in mxdList:
try:
mxdname = filename
mxd = arcpy.mapping.MapDocument(filename)
mxdleft = str(string.lstrip(filename, path))
mxdname = str(string.rstrip(mxdleft, ".mxd"))
print 'Processing ' + mxdname + '\n'
mxd.description = mxdname
print "Description = " + mxd.description
mxd.summary = mxdname
print "Summary = " + mxd.summary
mxd.tags = mxdname
print "Tag = " + mxd.tags + '\n'
# Save the MXD
mxd.save()
# Now Package the mxd
# Read Data Frames, Identify Raster Layers and Remove them.
print 'Reading Data Frames...'
DF = arcpy.mapping.ListDataFrames(mxd)
print '...Found ' + str(len(DF)) + ' Data Frames' + '\n'
for DF in arcpy.mapping.ListDataFrames(mxd):
DFname = DF.name
print "Processing - " + str(DFname)
lyrs = arcpy.mapping.ListLayers(mxd)
for lyrs in arcpy.mapping.ListLayers(mxd):
if lyrs.isBroken:
print lyrs.name + " is Broken."
break
if lyrs.isRasterLayer:
print "Found Raster - " + str(lyrs)
# Part to actually remove the raster, uses the data frame (DF) and the layer (lyrs)
arcpy.mapping.RemoveLayer(DF, lyrs)
print str(lyrs) + " Removed"
# After the changes made, we need to save the MXD.
mxd.save()
print '\n' + "All Rasters Removed"
print "\n" + "Packaging " + mxdname
arcpy.PackageMap_management(filename,
os.path.splitext(filename)[0] + '.mpk', "CONVERT", "CONVERT_ARCSDE", "#", "ALL")
print mxdname + " Packaged Successfully"
successcount += 1
outFile.write(mxdname + "," + "Packaged" + "," + "None" + "\n")
del mxd, mxdname, DF
except Exception as e:
print "-----"
print "Error"
traceback.print_exc()
error = str(e.message.split('\r\n'))
print "Problem With " + mxdname
print "Ignoring Error, Like A Boss"
outFile.write(mxdname + "," + "Not Packaged" + "," + error.replace('\n', ' ') + "\n")
failcount += 1
continue
# End Statement to display basic statistics.
print "\n"
print "Finished"
print str(successcount) + " MXDs Packaged Successfully - " + str(failcount) + " MXDs Failed"
print "Check Output Log For Details"
# Release the CSV logfile
outFile.close()