Export Multiple MXDs to JPG

1176
2
Jump to solution
05-05-2012 05:05 PM
RebeccaRothbard
New Contributor
I need to export several individual MXDs (not within the context of a map book) to JPG. I understand the simple Python script used to export one at a time, but I need to be more efficient and export several at once. Any thoughts/suggestions?

Rebecca
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JeffBarrette
Esri Regular Contributor
The following script will export all MXDs in a folder to JPG:

import arcpy, os inputPath = some path outputPath = some other path  #Loop through each MXD file for filename in os.listdir(inputPath):     fullpath = os.path.join(inputPath, filename)     if os.path.isfile(fullpath):         if filename.lower().endswith(".mxd"):              #Reference MXD and export             mxd = arcpy.mapping.MapDocument(fullpath)             arcpy.mapping.ExportToJPEG(mxd, outputPath + "\\" + filename + ".jpg")


Jeff

View solution in original post

0 Kudos
2 Replies
JeffBarrette
Esri Regular Contributor
The following script will export all MXDs in a folder to JPG:

import arcpy, os inputPath = some path outputPath = some other path  #Loop through each MXD file for filename in os.listdir(inputPath):     fullpath = os.path.join(inputPath, filename)     if os.path.isfile(fullpath):         if filename.lower().endswith(".mxd"):              #Reference MXD and export             mxd = arcpy.mapping.MapDocument(fullpath)             arcpy.mapping.ExportToJPEG(mxd, outputPath + "\\" + filename + ".jpg")


Jeff
0 Kudos
Raphael_Augusto_FoscariniFerre
Occasional Contributor
Awesome!!
I changed something:

The output name will not be "map_document.mxd.jpg" anymore... It'll be just "map_document.jpg"

And you can set some quality options (DPI and compression):


import arcpy, os
inputPath = os.curdir
outputPath = os.curdir

#Loop through each MXD file
for filename in os.listdir(inputPath):
    fullpath = os.path.join(inputPath, filename)
    if os.path.isfile(fullpath):
        if filename.lower().endswith(".mxd"):

            #Reference MXD and export
            mxd = arcpy.mapping.MapDocument(fullpath)
            OutputJPGPath = os.path.join(outputPath, filename.replace(".mxd", ".jpg"))
            #arcpy.mapping.ExportToJPEG(mxd, OutputJPGPath)
            arcpy.mapping.ExportToJPEG(mxd, OutputJPGPath, 'PAGE_LAYOUT', 0, 0, 200, "False", '24-BIT_TRUE_COLOR', 100)
0 Kudos