rgthurau

Batch export mxd, python mapping module

Discussion created by rgthurau on Oct 21, 2011
Latest reply on Oct 21, 2011 by rgthurau
Hi esri community,
I'm trying to use a fairly simple script to export a list of map layouts (mxds) in a folder to pngs. should be easy but...

import arcpy
ws = arcpy.env.workspace = "X:\\Draft3Maps"
outDir = "X:\\Draft3_Map_graphics"

mapList = arcpy.ListFiles("*.mxd")
arcpy.mapping.MapDocument(mapList)
for mxd in mapList:
    #arcpy.mapping.MapDocument(mxd)
    print mxd
    arcpy.mapping.ExportToPNG(mxd, outDir + '\\' + str(mxd))
    del mxd


Error message:
Traceback (most recent call last):
  File "X:\export_mxd_to_PNG.py", line 8, in <module>
    arcpy.mapping.MapDocument(mapList)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\mixins.py", line 443, in __init__
    assert (os.path.isfile(mxd) or (mxd.lower() == "current")), gp.getIDMessage(89004, "Invalid MXD filename")
  File "C:\Apps\Python26\ArcGIS10.0\lib\genericpath.py", line 29, in isfile
    st = os.stat(path)
TypeError: coercing to Unicode: need string or buffer, list found

I know I'm probably close but probably missing something key. Any help is greatly appreciated.

Rich

Outcomes