0

Okay, so I can feel that I am so close to solving this issue with the help of Jason (below) but I have modified to use as a script. The GetParameterAsText returns the following error when trying to execute:

: [Error 3] The system cannot find the path specified: u"'C:\Users\bob\Documents\folder\file.mxd';'C:\Users\folder\Documents\Folder\file.mxd';'C:\Users\folder\Documents\folder\file.mxd'\*.*"

Anyone know what is wrong with my code to keep getting this error?

    import arcpy, os, string

    #Read input/output folder path from script tool
    folderPath = arcpy.GetParameterAsText(0)
    outPNGfolder = arcpy.GetParameterAsText(1)

    for filename in os.listdir(folderPath):
        fullpath = os.path.join(folderPath, filename)
        if os.path.isfile(fullpath):
            basename, extension = os.path.splitext(fullpath)
            if extension.lower() == ".mxd":
                mxd = arcpy.mapping.MapDocument(fullpath)
                arcpy.mapping.ExportToPNG(mxd, basename + '.png')
6
  • What is "mapping.PNGDcoumentCreate(outPNGpath)? This isn't a real mapping function. You don't need this line. You can download Pyscripter (free) and learn to debug your script.
    – klewis
    Aug 14, 2013 at 13:37
  • I was trying to modify an existing script that batch converts multiple map documents into a single PDF. I am new to all of this but couldn't find a simple solution to batch export multiple mxds into pngs thru model builder so I naturally migrated to python. I will look into pyscripter. Thank you.
    – newbie123
    Aug 14, 2013 at 14:46
  • The ESRI online help has nice examples on how to use various arcpy.mapping functions & classes. help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//…
    – klewis
    Aug 14, 2013 at 16:52
  • What are you passing as your parameters? It should just be a single directory path.
    – Tom
    Aug 21, 2013 at 17:10
  • 1
    @Tom - can you please make that an answer. Oct 8, 2013 at 16:03

1 Answer 1

3

From Jeff Moulds (ESRI) originally for pdf export here's some python you can customize. It works on all mxds in a folder so you could adjust that or perhaps copy the projects into one temporarily for exporting. I added paragraph spaces after the first 3 lines to make the text properly indent in the box below, not being smart enough to do that any other way.

import arcpy, os
folderPath = r"C:\Project"
for filename in os.listdir(folderPath):
    fullpath = os.path.join(folderPath, filename)
    if os.path.isfile(fullpath):
        basename, extension = os.path.splitext(fullpath)
        if extension.lower() == ".mxd":
            mxd = arcpy.mapping.MapDocument(fullpath)
            arcpy.mapping.ExportToPNG(mxd, basename + '.png')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.