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')
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Aug 14, 2013 at 13:09
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. Commented 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. Commented 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#//… Commented Aug 14, 2013 at 16:52
  • What are you passing as your parameters? It should just be a single directory path. Commented Aug 21, 2013 at 17:10
  • 1
    @Tom - can you please make that an answer. Commented 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')
Jason Scheirer
18k2 gold badges55 silver badges72 bronze badges
answered Aug 14, 2013 at 16:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.