Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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')
share|improve this question
    
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 '13 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 '13 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 '13 at 16:52
    
What are you passing as your parameters? It should just be a single directory path. –  Tom Aug 21 '13 at 17:10
1  
@Tom - can you please make that an answer. –  Jakub Oct 8 '13 at 16:03
show 1 more comment

1 Answer

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')
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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