<?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 Data Driven Pages - Creating folders in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/data-driven-pages-creating-folders/m-p/876696#M4937</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new to python, and was wondering if there is a way to incorporate folder creation as part of my data driven page script, see below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... in_folder = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... file_name = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pageName = mxd.dataDrivenPages.pageRow.Name&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToJPEG(mxd, r"C:\Folder path\ " + pageName + "_Landcapability.jpeg", resolution=250)&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... del mxd&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... del df&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;So basically I have 12 data sets consisting of either raster or vector data sets and one main data set (properties) which forms my data driven page. What I will do is, I will for instance switch on my land capability data set and run the script, when it is finished I will switch the next data set on and run the script again until I finished all 12 data sets. My pageName is the property code, therefore I will have 12 maps per property code. I then go and create folders for each property code, lets say 001 and move all 12 maps into that folder, and so forth for the rest. Is there a way of optimising this process, so that I don't manually have to switch on and of the layers and also so that I don't have to go manually create folders for each property code. It is over a 1000 properties, so currently it is a very time consuming process.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;Any help will be appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 30 Oct 2018 13:05:21 GMT</pubDate>
    <dc:creator>LieslDe_Swardt1</dc:creator>
    <dc:date>2018-10-30T13:05:21Z</dc:date>
    <item>
      <title>Data Driven Pages - Creating folders</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/data-driven-pages-creating-folders/m-p/876696#M4937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new to python, and was wondering if there is a way to incorporate folder creation as part of my data driven page script, see below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... in_folder = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... file_name = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pageName = mxd.dataDrivenPages.pageRow.Name&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToJPEG(mxd, r"C:\Folder path\ " + pageName + "_Landcapability.jpeg", resolution=250)&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... del mxd&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;... del df&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;So basically I have 12 data sets consisting of either raster or vector data sets and one main data set (properties) which forms my data driven page. What I will do is, I will for instance switch on my land capability data set and run the script, when it is finished I will switch the next data set on and run the script again until I finished all 12 data sets. My pageName is the property code, therefore I will have 12 maps per property code. I then go and create folders for each property code, lets say 001 and move all 12 maps into that folder, and so forth for the rest. Is there a way of optimising this process, so that I don't manually have to switch on and of the layers and also so that I don't have to go manually create folders for each property code. It is over a 1000 properties, so currently it is a very time consuming process.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;/P&gt;&lt;P style="text-indent: -5.0pt; margin: 0cm 0cm .0001pt 5.0pt;"&gt;&lt;SPAN style="font-size: 12.0pt; color: black;"&gt;Any help will be appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2018 13:05:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/data-driven-pages-creating-folders/m-p/876696#M4937</guid>
      <dc:creator>LieslDe_Swardt1</dc:creator>
      <dc:date>2018-10-30T13:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages - Creating folders</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/data-driven-pages-creating-folders/m-p/876697#M4938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The accepted answer in this link is safe.. there are old (aka python 2.7) and current methods covered in the thread&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://stackoverflow.com/questions/273192/how-can-i-safely-create-a-nested-directory-in-python" title="https://stackoverflow.com/questions/273192/how-can-i-safely-create-a-nested-directory-in-python"&gt;exception - How can I safely create a nested directory in Python? - Stack Overflow&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2018 13:17:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/data-driven-pages-creating-folders/m-p/876697#M4938</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-10-30T13:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages - Creating folders</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/data-driven-pages-creating-folders/m-p/876698#M4939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanx Dan this helps a lot, I am still a bit confused though, not sure where to incorporate the script in my script. I should actually state that I have no knowledge in python at all&amp;nbsp;&lt;SPAN style="color: #222222; background-color: #ffffff; font-size: 16px;"&gt;&amp;nbsp; .&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2018 13:33:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/data-driven-pages-creating-folders/m-p/876698#M4939</guid>
      <dc:creator>LieslDe_Swardt1</dc:creator>
      <dc:date>2018-10-30T13:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages - Creating folders</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/data-driven-pages-creating-folders/m-p/876699#M4940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;grief... why are you starting with the python api then &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/wink.png" /&gt;&lt;/P&gt;&lt;P&gt;You have to import a module before you can use it.&amp;nbsp; So let's skip 'safe' and just get to the point. &amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case, your script needs to include&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import os

os.makedirs("c:/Temp/Test")&amp;nbsp; # enter the path to create&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Use forward slashes for now (read up on 'raw' encoding for later)&lt;/P&gt;&lt;P&gt;If it doesn't work, failure will eventually bring enlightenment&lt;/P&gt;&lt;P&gt;Welcome to python... and start learning python 3.x (ie ArcGIS PRO's python) since 2.7 is terminal (yeah yeah, skip the it will be around for a long time stories)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 11:00:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/data-driven-pages-creating-folders/m-p/876699#M4940</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T11:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Data Driven Pages - Creating folders</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/data-driven-pages-creating-folders/m-p/876700#M4941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Lol, I am just gonna&amp;nbsp;pretend that I know exactly what Python api is&amp;nbsp;&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So that means I will do the import os first, then put my data driven pages script, and then lastly put the os.makedirs script?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is actually an urgent process I was tasked with, so I think I will get it done in arcmap and then move over to ArcGIS Pro.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But thanks hey - you are of great help &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Oct 2018 14:18:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/data-driven-pages-creating-folders/m-p/876700#M4941</guid>
      <dc:creator>LieslDe_Swardt1</dc:creator>
      <dc:date>2018-10-30T14:18:55Z</dc:date>
    </item>
  </channel>
</rss>

