Hi Sean,
Try something like:
import arcpy, os
folderPath = r"C:\Project"
outFolder = r"C:\Project\PDFs" ## create an output folder
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.ExportToPDF(mxd, outFolder + basename + '.pdf')
You will probably need to create ‘PDFs’ folder before running script.
Regards,
Craig
C. Poynter
Information Technology Officer (Spatial Analysis) | Research Office, Spatial Data Analysis Network (SPAN)
Charles Sturt University
Boorooma Street
Wagga Wagga, NSW, 2678
Australia
Phone: +61 2 69332165
Fax: +61 2 69332735
Email: cpoynter@csu.edu.au<mailto:cpoynter@csu.edu.au>
www.csu.edu.au<http://www.csu.edu.au/>
Jeff, this works almost perfectly. In testing, it created PDF's out all my MXD's in a folder, but is it possible to output to a different folder? I tried messing around with your code but I don't have enough knowledge to get it to work.
thanks
Sean
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.ExportToPDF(mxd, basename + '.pdf')
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.