<?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 How export files pdf into multiple folders with the same name? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-export-files-pdf-into-multiple-folders-with/m-p/531968#M41655</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: rgba(248, 248, 248, 0.6);"&gt;I am not an expert on Python scripting but I undertand a few concepts about it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: rgba(248, 248, 248, 0.6);"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I made a script that export multiple individual mxd and pdf with a specific same name, also on my script, I can make multiple folders with the same name from mxd, but I dont know how put all the files on the same folders made. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible export all the files mxd, pdf which has the same name into folders with the same name?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This my script:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy, os&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wsp = r"D:\SedesolVQB\Proyectos\proyecto_PythonEjercicio\PracticasPython.mdb"&lt;BR /&gt;Shp = 'Estados'&lt;BR /&gt;pageNameField = "CVE_ENT" #&amp;lt;----this is the main field comun to save on folders, mxs and pdf&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mxdSalida = r"D:\SedesolVQB\Proyectos\proyecto_PythonEjercicio\Mapas finales"&lt;BR /&gt;mxdOrigen = r"D:\SedesolVQB\Proyectos\proyecto_PythonEjercicio\Mxd\Practicas.mxd" #&amp;lt;---This is the maind mxd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#To Make diferent folder from pageNameField&lt;BR /&gt;with arcpy.da.SearchCursor(Shp,(pageNameField)) as cursor:&lt;BR /&gt; for folder, in cursor:&lt;BR /&gt; os.makedirs(os.path.join(mxdSalida, str(folder)))&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Export to pdf file from each mxd and save mxd indivuals&lt;BR /&gt;for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):&lt;BR /&gt; mxd.dataDrivenPages.currentPageID = pageNum&lt;BR /&gt; pageName = mxd.dataDrivenPages.pageRow.getValue(pageNameField)&lt;/P&gt;&lt;P&gt;arcpy.mapping.ExportToPDF(mxd, os.path.join(mxdSalida, str(pageName) + ".pdf"))&lt;BR /&gt; mxdNombre = os.path.join(os.path.join(mxdSalida, str(pageName)),str(pageName)+".mxd")&lt;BR /&gt; mxd.saveACopy(mxdNombre)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print u"Exportando página {0} de {1}".format(str(mxd.dataDrivenPages.currentPageID), str(mxd.dataDrivenPages.pageCount))&lt;BR /&gt; print u"Guardando una copia de:{0}".format(str(pageName))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print "PROCESO TERMINADO"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result is something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;D:\SedesolVQB\Proyectos\proyecto_PythonEjercicio\Mapas finales\01\01.mxd\\---&amp;gt; 01.pdf (Is shown outside)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;D:\SedesolVQB\Proyectos\proyecto_PythonEjercicio\Mapas finales\02\02.mxd\\---&amp;gt; 02.pdf (Is shown outside)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;D:\SedesolVQB\Proyectos\proyecto_PythonEjercicio\Mapas finales\03\03.mxd\\---&amp;gt; 03.pdf (Is shown outside)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the file pdf remains outside from the folders, what I need all the files mxd and pdf into de the folders whit the same name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Mar 2017 01:28:51 GMT</pubDate>
    <dc:creator>VictorQuiroz1</dc:creator>
    <dc:date>2017-03-09T01:28:51Z</dc:date>
    <item>
      <title>How export files pdf into multiple folders with the same name?</title>
      <link>https://community.esri.com/t5/python-questions/how-export-files-pdf-into-multiple-folders-with/m-p/531968#M41655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: rgba(248, 248, 248, 0.6);"&gt;I am not an expert on Python scripting but I undertand a few concepts about it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #242729; background-color: rgba(248, 248, 248, 0.6);"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I made a script that export multiple individual mxd and pdf with a specific same name, also on my script, I can make multiple folders with the same name from mxd, but I dont know how put all the files on the same folders made. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible export all the files mxd, pdf which has the same name into folders with the same name?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This my script:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy, os&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wsp = r"D:\SedesolVQB\Proyectos\proyecto_PythonEjercicio\PracticasPython.mdb"&lt;BR /&gt;Shp = 'Estados'&lt;BR /&gt;pageNameField = "CVE_ENT" #&amp;lt;----this is the main field comun to save on folders, mxs and pdf&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mxdSalida = r"D:\SedesolVQB\Proyectos\proyecto_PythonEjercicio\Mapas finales"&lt;BR /&gt;mxdOrigen = r"D:\SedesolVQB\Proyectos\proyecto_PythonEjercicio\Mxd\Practicas.mxd" #&amp;lt;---This is the maind mxd&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#To Make diferent folder from pageNameField&lt;BR /&gt;with arcpy.da.SearchCursor(Shp,(pageNameField)) as cursor:&lt;BR /&gt; for folder, in cursor:&lt;BR /&gt; os.makedirs(os.path.join(mxdSalida, str(folder)))&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Export to pdf file from each mxd and save mxd indivuals&lt;BR /&gt;for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):&lt;BR /&gt; mxd.dataDrivenPages.currentPageID = pageNum&lt;BR /&gt; pageName = mxd.dataDrivenPages.pageRow.getValue(pageNameField)&lt;/P&gt;&lt;P&gt;arcpy.mapping.ExportToPDF(mxd, os.path.join(mxdSalida, str(pageName) + ".pdf"))&lt;BR /&gt; mxdNombre = os.path.join(os.path.join(mxdSalida, str(pageName)),str(pageName)+".mxd")&lt;BR /&gt; mxd.saveACopy(mxdNombre)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print u"Exportando página {0} de {1}".format(str(mxd.dataDrivenPages.currentPageID), str(mxd.dataDrivenPages.pageCount))&lt;BR /&gt; print u"Guardando una copia de:{0}".format(str(pageName))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print "PROCESO TERMINADO"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result is something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;D:\SedesolVQB\Proyectos\proyecto_PythonEjercicio\Mapas finales\01\01.mxd\\---&amp;gt; 01.pdf (Is shown outside)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;D:\SedesolVQB\Proyectos\proyecto_PythonEjercicio\Mapas finales\02\02.mxd\\---&amp;gt; 02.pdf (Is shown outside)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;D:\SedesolVQB\Proyectos\proyecto_PythonEjercicio\Mapas finales\03\03.mxd\\---&amp;gt; 03.pdf (Is shown outside)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the file pdf remains outside from the folders, what I need all the files mxd and pdf into de the folders whit the same name.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Mar 2017 01:28:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-export-files-pdf-into-multiple-folders-with/m-p/531968#M41655</guid>
      <dc:creator>VictorQuiroz1</dc:creator>
      <dc:date>2017-03-09T01:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: How export files pdf into multiple folders with the same name?</title>
      <link>https://community.esri.com/t5/python-questions/how-export-files-pdf-into-multiple-folders-with/m-p/531969#M41656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Victor,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;First off, for future reference when posting any sort of code on GeoNet, please use the code formatting so its easier for people to read.&amp;nbsp; &lt;A _jive_internal="true" href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting?sr=search&amp;amp;searchId=9e68ebfd-5533-4144-baae-76132a8a7e07&amp;amp;searchIndex=0"&gt;https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting?sr=search&amp;amp;searchId=9e68ebfd-5533-4144-baae-76132a8a7e07&amp;amp;searchIndex=0&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From your post it is my understanding that you want your MXD and PDF file for the map to be saved to the same number directory that was created from your search cursor and matches page number attribute of your DDP, but the pdf keeps ending up a directory above the MXD file(Mapas finales instead of the correct number folder).&amp;nbsp; I believe your issue would be in the fact that you are adding an extra directory to your filepath when creating your mxdNombre variable (mxdNombre = os.path.join(os.path.join(mxdSalida, str(pageName)),str(pageName)+".mxd")) whereas that extra folder path is not included when exporting the PDF (arcpy.mapping.ExportToPDF(mxd, os.path.join(mxdSalida, str(pageName) + ".pdf"))).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you added the extra os.path.join which joins the extra folder name to your PDF export, that should fix your problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;arcpy.mapping.ExportToPDF(mxd, os.path.join(os.path.join(mxdSalida, str(pageName)),str(pageName) + ".pdf"))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best wishes,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ian&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Mar 2017 14:19:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-export-files-pdf-into-multiple-folders-with/m-p/531969#M41656</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2017-03-09T14:19:48Z</dc:date>
    </item>
  </channel>
</rss>

