<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Batch Export a directory to PDFs and Data Driven Pages? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/batch-export-a-directory-to-pdfs-and-data-driven/m-p/777755#M1056</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've written a script to export all mxds in a directory to PDFs. The issue I'm running into is that some of those MXDs have data driven pages enabled, so they export only the first page. As far as I can tell I need to create a list of MXDs that have data driven pages enabled and then loop over that list and export. I get the following error when I run the code below:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "C:\Users\XXXX\Documents\ArcGIS\TBX.tbx#BatchExportToPDF.py", line 14, in &amp;lt;module&amp;gt;&lt;BR /&gt;TypeError: ListFiles() got an unexpected keyword argument 'isddpEnabled'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I generate a list of mxds with ddp enabled, and a list of mxds without it enabled, and then loop through both of them and get all my MXDs exported ?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #808080;"&gt;#Script takes all .mxd files in a user defined directory and
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;#exports them to the user defined directory
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;#imports relevant modules
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;os&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;arcpy

&lt;SPAN style="color: #808080;"&gt;#user sets input and output directories
&lt;/SPAN&gt;input_dir = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;)
output_dir = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;)

arcpy.env.workspace = ws = &lt;SPAN style="color: #8888c6;"&gt;str&lt;/SPAN&gt;(input_dir)

&lt;SPAN style="color: #808080;"&gt;#need to loop through mxd_list and grab docs where variablename.ddpenabled. if true the put in list
&lt;/SPAN&gt;mxd_list = arcpy.ListFiles(&lt;SPAN style="color: #a5c261;"&gt;"*.mxd"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;isddpEnabled &lt;/SPAN&gt;= &lt;SPAN style="color: #8888c6;"&gt;False&lt;/SPAN&gt;)
ddp_list = arcpy.ListFiles(&lt;SPAN style="color: #a5c261;"&gt;"*.mxd'"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;isddpEnabled &lt;/SPAN&gt;= &lt;SPAN style="color: #8888c6;"&gt;True&lt;/SPAN&gt;)

&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;mxd &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;mxd_list:
    &lt;SPAN style="color: #808080;"&gt;#creates variable that opens an arcmap document at input dir + .mxd
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;current_mxd = arcpy.mapping.MapDocument(os.path.join(ws&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;mxd))
    &lt;SPAN style="color: #808080;"&gt;#creates variable that stores output directory + mxd
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;pdf_name = (os.path.join(output_dir&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;mxd[:-&lt;SPAN style="color: #6897bb;"&gt;4&lt;/SPAN&gt;]) + &lt;SPAN style="color: #a5c261;"&gt;".pdf"&lt;/SPAN&gt;)
    &lt;SPAN style="color: #808080;"&gt;#exports the mxd to the output folder
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;arcpy.mapping.ExportToPDF(current_mxd&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;pdf_name)
    arcpy.AddMessage(&lt;SPAN style="color: #a5c261;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;\t&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;' &lt;/SPAN&gt;+ mxd + &lt;SPAN style="color: #8888c6;"&gt;str&lt;/SPAN&gt;(&lt;SPAN style="color: #a5c261;"&gt;' exported successfully.'&lt;/SPAN&gt;))
&lt;SPAN style="color: #cc7832;"&gt;del &lt;/SPAN&gt;mxd_list

&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;mxd &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;ddp_list:
    &lt;SPAN style="color: #808080;"&gt;#creates variable that opens an arcmap document at input dir + .mxd
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;current_mxd = arcpy.mapping.MapDocument(os.path.join(ws&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;mxd))
    &lt;SPAN style="color: #808080;"&gt;#creates variable that stores output directory + mxd
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;pdf_name = (os.path.join(output_dir&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;mxd[:-&lt;SPAN style="color: #6897bb;"&gt;4&lt;/SPAN&gt;]) + &lt;SPAN style="color: #a5c261;"&gt;".pdf"&lt;/SPAN&gt;)
    &lt;SPAN style="color: #808080;"&gt;#exports the ddp mxd to the output folder
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;ddp = current_mxd.dataDrivenPages
    ddp.datadrivenpages(pdf_name&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"ALL"&lt;/SPAN&gt;)
    arcpy.AddMessage(&lt;SPAN style="color: #a5c261;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;\t&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;' &lt;/SPAN&gt;+ mxd + &lt;SPAN style="color: #8888c6;"&gt;str&lt;/SPAN&gt;(&lt;SPAN style="color: #a5c261;"&gt;' exported successfully.'&lt;/SPAN&gt;))
&lt;SPAN style="color: #cc7832;"&gt;del &lt;/SPAN&gt;mxd_list

arcpy.AddMessage((&lt;SPAN style="color: #a5c261;"&gt;'Exports complete!'&lt;/SPAN&gt;))

complete = os.startfile(output_dir)
complete&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 08:45:04 GMT</pubDate>
    <dc:creator>ShelbyZemken1</dc:creator>
    <dc:date>2021-12-12T08:45:04Z</dc:date>
    <item>
      <title>Batch Export a directory to PDFs and Data Driven Pages?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/batch-export-a-directory-to-pdfs-and-data-driven/m-p/777755#M1056</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've written a script to export all mxds in a directory to PDFs. The issue I'm running into is that some of those MXDs have data driven pages enabled, so they export only the first page. As far as I can tell I need to create a list of MXDs that have data driven pages enabled and then loop over that list and export. I get the following error when I run the code below:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "C:\Users\XXXX\Documents\ArcGIS\TBX.tbx#BatchExportToPDF.py", line 14, in &amp;lt;module&amp;gt;&lt;BR /&gt;TypeError: ListFiles() got an unexpected keyword argument 'isddpEnabled'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I generate a list of mxds with ddp enabled, and a list of mxds without it enabled, and then loop through both of them and get all my MXDs exported ?&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #808080;"&gt;#Script takes all .mxd files in a user defined directory and
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;#exports them to the user defined directory
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;#imports relevant modules
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;import &lt;/SPAN&gt;os&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;arcpy

&lt;SPAN style="color: #808080;"&gt;#user sets input and output directories
&lt;/SPAN&gt;input_dir = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;)
output_dir = arcpy.GetParameterAsText(&lt;SPAN style="color: #6897bb;"&gt;1&lt;/SPAN&gt;)

arcpy.env.workspace = ws = &lt;SPAN style="color: #8888c6;"&gt;str&lt;/SPAN&gt;(input_dir)

&lt;SPAN style="color: #808080;"&gt;#need to loop through mxd_list and grab docs where variablename.ddpenabled. if true the put in list
&lt;/SPAN&gt;mxd_list = arcpy.ListFiles(&lt;SPAN style="color: #a5c261;"&gt;"*.mxd"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;isddpEnabled &lt;/SPAN&gt;= &lt;SPAN style="color: #8888c6;"&gt;False&lt;/SPAN&gt;)
ddp_list = arcpy.ListFiles(&lt;SPAN style="color: #a5c261;"&gt;"*.mxd'"&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #aa4926;"&gt;isddpEnabled &lt;/SPAN&gt;= &lt;SPAN style="color: #8888c6;"&gt;True&lt;/SPAN&gt;)

&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;mxd &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;mxd_list:
    &lt;SPAN style="color: #808080;"&gt;#creates variable that opens an arcmap document at input dir + .mxd
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;current_mxd = arcpy.mapping.MapDocument(os.path.join(ws&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;mxd))
    &lt;SPAN style="color: #808080;"&gt;#creates variable that stores output directory + mxd
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;pdf_name = (os.path.join(output_dir&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;mxd[:-&lt;SPAN style="color: #6897bb;"&gt;4&lt;/SPAN&gt;]) + &lt;SPAN style="color: #a5c261;"&gt;".pdf"&lt;/SPAN&gt;)
    &lt;SPAN style="color: #808080;"&gt;#exports the mxd to the output folder
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;arcpy.mapping.ExportToPDF(current_mxd&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;pdf_name)
    arcpy.AddMessage(&lt;SPAN style="color: #a5c261;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;\t&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;' &lt;/SPAN&gt;+ mxd + &lt;SPAN style="color: #8888c6;"&gt;str&lt;/SPAN&gt;(&lt;SPAN style="color: #a5c261;"&gt;' exported successfully.'&lt;/SPAN&gt;))
&lt;SPAN style="color: #cc7832;"&gt;del &lt;/SPAN&gt;mxd_list

&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;mxd &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;ddp_list:
    &lt;SPAN style="color: #808080;"&gt;#creates variable that opens an arcmap document at input dir + .mxd
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;current_mxd = arcpy.mapping.MapDocument(os.path.join(ws&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;mxd))
    &lt;SPAN style="color: #808080;"&gt;#creates variable that stores output directory + mxd
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;pdf_name = (os.path.join(output_dir&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;mxd[:-&lt;SPAN style="color: #6897bb;"&gt;4&lt;/SPAN&gt;]) + &lt;SPAN style="color: #a5c261;"&gt;".pdf"&lt;/SPAN&gt;)
    &lt;SPAN style="color: #808080;"&gt;#exports the ddp mxd to the output folder
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;ddp = current_mxd.dataDrivenPages
    ddp.datadrivenpages(pdf_name&lt;SPAN style="color: #cc7832;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;"ALL"&lt;/SPAN&gt;)
    arcpy.AddMessage(&lt;SPAN style="color: #a5c261;"&gt;'&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;\t&lt;/SPAN&gt;&lt;SPAN style="color: #a5c261;"&gt;' &lt;/SPAN&gt;+ mxd + &lt;SPAN style="color: #8888c6;"&gt;str&lt;/SPAN&gt;(&lt;SPAN style="color: #a5c261;"&gt;' exported successfully.'&lt;/SPAN&gt;))
&lt;SPAN style="color: #cc7832;"&gt;del &lt;/SPAN&gt;mxd_list

arcpy.AddMessage((&lt;SPAN style="color: #a5c261;"&gt;'Exports complete!'&lt;/SPAN&gt;))

complete = os.startfile(output_dir)
complete&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:45:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/batch-export-a-directory-to-pdfs-and-data-driven/m-p/777755#M1056</guid>
      <dc:creator>ShelbyZemken1</dc:creator>
      <dc:date>2021-12-12T08:45:04Z</dc:date>
    </item>
  </channel>
</rss>

