<?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 Re: Recursive conversion from shp to FileGDB through folders and subfolders in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/recursive-conversion-from-shp-to-filegdb-through/m-p/543215#M42363</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No, the indentation isn't correct and thanks for the catch on fcs_in_workspace. Nerves got the best of me while I was setting up, with it being my first post and all. I will test the != idea and get back to you. Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 Apr 2012 17:01:17 GMT</pubDate>
    <dc:creator>JonathonBruce</dc:creator>
    <dc:date>2012-04-20T17:01:17Z</dc:date>
    <item>
      <title>Recursive conversion from shp to FileGDB through folders and subfolders</title>
      <link>https://community.esri.com/t5/python-questions/recursive-conversion-from-shp-to-filegdb-through/m-p/543213#M42361</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to convert all shapefiles into feature classes in my directory, including what's inside sub-folders. The code that I've compiled below (from reading previous answers and trial &amp;amp; error on my part) accomplishes this, but it seems that it also begins to iterate through the newly created GDB as well, which is bad. Any advice or insight would be greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy from arcpy import env import os&amp;nbsp; path = 'C:\\Data' env.workspace = path&amp;nbsp; arcpy.management.CreateFileGDB(env.workspace,"Project","10.0")&amp;nbsp;&amp;nbsp; try: &amp;nbsp;&amp;nbsp;&amp;nbsp; def fcs_in_workspace(workspace): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; env.workspace = workspace &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in arcpy.ListFeatureClasses(): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yield fc &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for ws in arcpy.ListWorkspaces(): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs_in_workspace(os.path.join(workspace, ws)): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yield fc&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OutGDB = env.workspace +'\\Project.gdb'&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs_in_workspace(env.workspace): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToGeodatabase_conversion(fc,OutGDB) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(fc +' copied.') &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except Exception as e: &amp;nbsp;&amp;nbsp;&amp;nbsp; print(e) else: &amp;nbsp;&amp;nbsp;&amp;nbsp; env.workspace = path &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CompressFileGeodatabaseData_management(OutGDB) &amp;nbsp;&amp;nbsp;&amp;nbsp; print(OutGDB + " has been compressed.") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Apr 2012 16:30:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/recursive-conversion-from-shp-to-filegdb-through/m-p/543213#M42361</guid>
      <dc:creator>JonathonBruce</dc:creator>
      <dc:date>2012-04-20T16:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive conversion from shp to FileGDB through folders and subfolders</title>
      <link>https://community.esri.com/t5/python-questions/recursive-conversion-from-shp-to-filegdb-through/m-p/543214#M42362</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is "for fc in fcs_workspace(env.workspace):" supposed to be "for fc in fcs_&lt;/SPAN&gt;&lt;STRONG&gt;in_&lt;/STRONG&gt;&lt;SPAN&gt;workspace(env.workspace):"? Also, is the indentation above truly correct? It doesn't look like you ever actually call the function "fcs_in_workspace".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In any case, you should somewhere test "if workspace != 'Project.gdb': ", or remove the workspace from your list of workspaces altogether.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Apr 2012 16:46:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/recursive-conversion-from-shp-to-filegdb-through/m-p/543214#M42362</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2012-04-20T16:46:50Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive conversion from shp to FileGDB through folders and subfolders</title>
      <link>https://community.esri.com/t5/python-questions/recursive-conversion-from-shp-to-filegdb-through/m-p/543215#M42363</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No, the indentation isn't correct and thanks for the catch on fcs_in_workspace. Nerves got the best of me while I was setting up, with it being my first post and all. I will test the != idea and get back to you. Thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Apr 2012 17:01:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/recursive-conversion-from-shp-to-filegdb-through/m-p/543215#M42363</guid>
      <dc:creator>JonathonBruce</dc:creator>
      <dc:date>2012-04-20T17:01:17Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive conversion from shp to FileGDB through folders and subfolders</title>
      <link>https://community.esri.com/t5/python-questions/recursive-conversion-from-shp-to-filegdb-through/m-p/543216#M42364</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Your idea worked! Here is the code as of current:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy,os
from arcpy import env

path = 'E:\\GDBConversionProject\\2062 Cabin Bluff'
env.workspace = path

arcpy.management.CreateFileGDB(env.workspace,"Project","10.0")


try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; def fcs_in_workspace(workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; env.workspace = workspace
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in arcpy.ListFeatureClasses():
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yield fc
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for ws in arcpy.ListWorkspaces():
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs_in_workspace(os.path.join(workspace, ws)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ws != path +"\\Project.gdb":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; yield fc

&amp;nbsp;&amp;nbsp;&amp;nbsp; OutGDB = env.workspace +'\\Project.gdb'

&amp;nbsp;&amp;nbsp;&amp;nbsp; for fc in fcs_in_workspace(env.workspace):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToGeodatabase_conversion(fc,OutGDB)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(fc +' copied.')
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
except Exception as e:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(e)
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; env.workspace = path
&amp;nbsp;&amp;nbsp;&amp;nbsp; print("Compressing FileGDB.")
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CompressFileGeodatabaseData_management(OutGDB)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print(OutGDB + " has been compressed.")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 23:31:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/recursive-conversion-from-shp-to-filegdb-through/m-p/543216#M42364</guid>
      <dc:creator>JonathonBruce</dc:creator>
      <dc:date>2021-12-11T23:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive conversion from shp to FileGDB through folders and subfolders</title>
      <link>https://community.esri.com/t5/python-questions/recursive-conversion-from-shp-to-filegdb-through/m-p/543217#M42365</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Question about the importance of this script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is this your companies (organization's) policy to convert shapefiles to file geodatabases?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or is ESRI dictating this move because shapefiles are going to be deprecated in the near future?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 Apr 2012 19:26:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/recursive-conversion-from-shp-to-filegdb-through/m-p/543217#M42365</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2012-04-20T19:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Recursive conversion from shp to FileGDB through folders and subfolders</title>
      <link>https://community.esri.com/t5/python-questions/recursive-conversion-from-shp-to-filegdb-through/m-p/543218#M42366</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Question about the importance of this script:&lt;BR /&gt;&lt;BR /&gt;Is this your companies (organization's) policy to convert shapefiles to file geodatabases?&lt;BR /&gt;&lt;BR /&gt;Or is ESRI dictating this move because shapefiles are going to be deprecated in the near future?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It was an internal company shift from shapefiles to FGDB's.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Nov 2012 16:23:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/recursive-conversion-from-shp-to-filegdb-through/m-p/543218#M42366</guid>
      <dc:creator>JonathonBruce</dc:creator>
      <dc:date>2012-11-20T16:23:09Z</dc:date>
    </item>
  </channel>
</rss>

