MapExportTools.py
def execute(self, parameters, messages):
        """The source code of the tool."""
        import os

        source = parameters[0].valueAsText
        destination = parameters[1].valueAsText
        outFormat = parameters[2].valueAsText

        for root, dirs, files, in os.walk(source):
            for fname in files:
                # loop for mxd files
                if fname[-3:] in ["mxd", "MXD"]:
                    filePath = source + "\\" + fname
                    mxd = arcpy.mapping.MapDocument(filePath)
                    # make files and export
                    if outFormat == "PDF":
                        savePath = os.path.join(destination + "\\" + fname[:-4] + ".pdf")
                        print savePath
                        arcpy.mapping.ExportToPDF(mxd, savePath, resolution=300)
                    elif outFormat == "PNG":
                        savePath = os.path.join(destination + "\\" + fname[:-4] + ".png")
                        print savePath
                        arcpy.mapping.ExportToPNG(mxd, savePath, resolution=300)
                    elif outFormat == "JPEG":
                        savePath = os.path.join(destination + "\\" + fname[:-4] + ".jpeg")
                        print savePath
                        arcpy.mapping.ExportToJPEG(mxd, savePath, resolution=300)
The source code of the tool.
The source code of the tool.
The source code of the tool .
def execute(self, parameters, messages):
        import os
        source = parameters[0].valueAsText
        destination = parameters[1].valueAsText
        outFormat = parameters[2].valueAsText
        for root, dirs, files, in os.walk(source):
            for fname in files:
                if fname[-3:] in ["mxd", "MXD"]:
                    filePath = source + "\\" + fname
                    mxd = arcpy.mapping.MapDocument(filePath)
                    if outFormat == "PDF":
                        savePath = os.path.join(destination + "\\" + fname[:-4] + ".pdf")
                        print savePath
                        arcpy.mapping.ExportToPDF(mxd, savePath, resolution=300)
                    elif outFormat == "PNG":
                        savePath = os.path.join(destination + "\\" + fname[:-4] + ".png")
                        print savePath
                        arcpy.mapping.ExportToPNG(mxd, savePath, resolution=300)
                    elif outFormat == "JPEG":
                        savePath = os.path.join(destination + "\\" + fname[:-4] + ".jpeg")
                        print savePath
                        arcpy.mapping.ExportToJPEG(mxd, savePath, resolution=300)
def execute ( self , parameters , messages ) : import os source = parameters [ 0 ] . valueAsText destination = parameters [ 1 ] . valueAsText outFormat = parameters [ 2 ] . valueAsText for root , dirs , files , in os . walk ( source ) : for fname in files : if fname [ - 3 : ] in [ "mxd" , "MXD" ] : filePath = source + "\\" + fname mxd = arcpy . mapping . MapDocument ( filePath ) if outFormat == "PDF" : savePath = os . path . join ( destination + "\\" + fname [ : - 4 ] + ".pdf" ) print savePath arcpy . mapping . ExportToPDF ( mxd , savePath , resolution = 300 ) elif outFormat == "PNG" : savePath = os . path . join ( destination + "\\" + fname [ : - 4 ] + ".png" ) print savePath arcpy . mapping . ExportToPNG ( mxd , savePath , resolution = 300 ) elif outFormat == "JPEG" : savePath = os . path . join ( destination + "\\" + fname [ : - 4 ] + ".jpeg" ) print savePath arcpy . mapping . ExportToJPEG ( mxd , savePath , resolution = 300 )
The source code of the tool.
The source code of the tool .
"""The source code of the tool.""" # loop for mxd files # make files and export
self
parameters
messages