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
# Import the required python modules
from arcpy import env
# Set some variables for the input MXDs
print 'Setting Paths'
path = raw_input('File Path to Folder Containing MXDs : ')
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:
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
# 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):
print lyrs.name + " is Broken."
print "Found Raster - " + str(lyrs)
# Part to actually remove the raster, uses the data frame (DF) and the layer (lyrs)
print str(lyrs) + " Removed"
# After the changes made, we need to save the MXD.
print '\n' + "All Rasters Removed"
print "\n" + "Packaging " + mxdname
os.path.splitext(filename) + '.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:
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
# End Statement to display basic statistics.
print str(successcount) + " MXDs Packaged Successfully - " + str(failcount) + " MXDs Failed"
print "Check Output Log For Details"
# Release the CSV logfile