import arcpy
import os
def batch_export_maps(mxd_folder, output_folder, export_format, resolution):
arcpy.env.workspace = mxd_folder
mxd_list = arcpy.ListFiles("*.mxd")
for mxd_file in mxd_list:
try:
mxd_path = os.path.join(mxd_folder, mxd_file)
mxd = arcpy.mapping.MapDocument(mxd_path)
output_file_name, _ = os.path.splitext(mxd_file)
output_path = os.path.join(output_folder, output_file_name + '.' + export_format.lower())
if export_format.upper() == 'PDF':
arcpy.mapping.ExportToPDF(mxd, output_path, resolution=resolution)
elif export_format.upper() == 'PNG':
arcpy.mapping.ExportToPNG(mxd, output_path, resolution=resolution)
elif export_format.upper() == 'JPG':
arcpy.mapping.ExportToJPEG(mxd, output_path, resolution=resolution)
elif export_format.upper() == 'EMF':
arcpy.mapping.ExportToEMF(mxd, output_path, resolution=resolution)
else:
arcpy.AddError("Unsupported export format: {}".format(export_format))
except Exception as e:
arcpy.AddError("Failed to export {}: {}".format(mxd_file))
arcpy.AddError(str(e))
arcpy.AddMessage("Batch export completed.")
if __name__ == '__main__':
mxd_folder = arcpy.GetParameterAsText(0)
output_folder = arcpy.GetParameterAsText(1)
export_format = arcpy.GetParameterAsText(2)
resolution = arcpy.GetParameter(3)
batch_export_maps(os.path.abspath(mxd_folder), os.path.abspath(output_folder), export_format, resolution)
09-18