<?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 combining 'create folder' and 'iterate feature classes' in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/combining-create-folder-and-iterate-feature/m-p/71374#M2521</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a folder with different subfolders and I want to copy all the features in it to new created folders with the same structure &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried as below but then all my features are putted in the same folder&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In other words, I have a folder 'X', with 2 subfolders 'Y' and 'Z'. The subfolders contain 3 shapes (T10, T100, T1000). I want under folder 'X', in subfolder 'Y' a new subfolder 'copy' with a copy of the 3 shapes in subfolder 'Y';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;in subfolder 'Z' I want a new subfolder 'copy' with a copy of the 3 shapes in subfolder 'Z'; instead of one new subfolder 'copy' under folder 'X' with the 6 shapes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Apr 2014 08:46:41 GMT</pubDate>
    <dc:creator>sveadauwe</dc:creator>
    <dc:date>2014-04-09T08:46:41Z</dc:date>
    <item>
      <title>combining 'create folder' and 'iterate feature classes'</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/combining-create-folder-and-iterate-feature/m-p/71374#M2521</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a folder with different subfolders and I want to copy all the features in it to new created folders with the same structure &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried as below but then all my features are putted in the same folder&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In other words, I have a folder 'X', with 2 subfolders 'Y' and 'Z'. The subfolders contain 3 shapes (T10, T100, T1000). I want under folder 'X', in subfolder 'Y' a new subfolder 'copy' with a copy of the 3 shapes in subfolder 'Y';&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;in subfolder 'Z' I want a new subfolder 'copy' with a copy of the 3 shapes in subfolder 'Z'; instead of one new subfolder 'copy' under folder 'X' with the 6 shapes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Apr 2014 08:46:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/combining-create-folder-and-iterate-feature/m-p/71374#M2521</guid>
      <dc:creator>sveadauwe</dc:creator>
      <dc:date>2014-04-09T08:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: combining 'create folder' and 'iterate feature classes'</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/combining-create-folder-and-iterate-feature/m-p/71375#M2522</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm not sure of a modelbuilder solution, but there should be a pretty easy way to do this in python.&amp;nbsp; I wrote out some quick code, if you know python you probably can get it to work for you.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; 
#Import Modules
import arcpy
from arcpy import env

#Defining Workspace
rootfolder = #Enter Location of folder 'X' here
env.workspace = rootfolder

#Listing all folder in workspace
listfolders = arcpy.ListWorkspaces()


for folder in listfolders:
&amp;nbsp;&amp;nbsp;&amp;nbsp; env.workspace = folder
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateFolder_management(folder, "copy")
&amp;nbsp;&amp;nbsp;&amp;nbsp; listfc = arcpy.ListFeatureClasses()
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in listfc:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; desc = arcpy.Describe(fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = desc.basename
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion(fc, folder + "/copy", name)

&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tested the code and it made a folder named copy in subfolder Y and Z with the shapefiles that were subfolders Y and Z in them(they are still also in subfolder Y and Z)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:45:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/combining-create-folder-and-iterate-feature/m-p/71375#M2522</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2021-12-10T22:45:21Z</dc:date>
    </item>
  </channel>
</rss>

