Select to view content in your preferred language

Python code to make my script run every day replacing the pdf file with a new one

605
3
10-23-2013 09:31 AM
JosephGrove
Deactivated User
I am very new to Python and have just made a script that will create a map book pdf file.  What I am trying to do now is determine what python script I would have to add to make this run every day to create an updated map book while deleting the map book pdf file from the previous day.  Here is the code I have so far:

import arcpy
pdfpath = "P:/Projects/Joseph/Map Book/Lewisville Parcel Map Book.pdf"
pdfdoc = arcpy.mapping.PDFDocumentCreate("P:/Projects/Joseph/Map Book/Lewisville Parcel Map Book.pdf")
mapdoc = arcpy.mapping.MapDocument("P:/Projects/Joseph/Map Book/MapBook.mxd")
mapdoc.dataDrivenPages.exportToPDF("P:/Projects/Joseph/Map Book/Lewisville Parcel Map Book.pdf")
pdfdoc.appendPages("P:/Projects/Joseph/Map Book/Cover.pdf")
pdfdoc.appendPages("P:/Projects/Joseph/Map Book/Lewisville Parcel Map Book.pdf")
pdfdoc.saveAndClose()
del mapdoc

Thank you in advance for your help.
Tags (2)
0 Kudos
3 Replies
MattSayler
Frequent Contributor
As long as the computer running it has python installed and the system variables are setup properly (i.e. if you double click on a .py file, it runs without asking what program to use), you can just set it up as a scheduled task in the Windows Task Scheduler or another program that provides the same sort of functionality (most RDBMS).
0 Kudos
JasonScheirer
Esri Alum
0 Kudos
JosephGrove
Deactivated User
Thank you so much for your answers and for the link to the blog post about setting up the task scheduler to run Python scripts.  This was very helpful and my script is now running successfully.

Thank you again.  Have a great day!
0 Kudos