<?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 Delete all empty feature class from folders and subfolder in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/delete-all-empty-feature-class-from-folders-and/m-p/730224#M56646</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;maybe you can help to create a Python script, with which I could delete empty feature class and shp file from subdirectory and directory&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Rubi&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 Oct 2014 13:04:45 GMT</pubDate>
    <dc:creator>RuBi</dc:creator>
    <dc:date>2014-10-01T13:04:45Z</dc:date>
    <item>
      <title>Delete all empty feature class from folders and subfolder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-feature-class-from-folders-and/m-p/730224#M56646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;maybe you can help to create a Python script, with which I could delete empty feature class and shp file from subdirectory and directory&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Rubi&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2014 13:04:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-feature-class-from-folders-and/m-p/730224#M56646</guid>
      <dc:creator>RuBi</dc:creator>
      <dc:date>2014-10-01T13:04:45Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty feature class from folders and subfolder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-feature-class-from-folders-and/m-p/730225#M56647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Have a look there:&lt;/P&gt;&lt;P&gt;&lt;A href="http://pymotw.com/2/glob/" title="http://pymotw.com/2/glob/"&gt;glob – Filename pattern matching - Python Module of the Week&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2014 13:09:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-feature-class-from-folders-and/m-p/730225#M56647</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2014-10-01T13:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty feature class from folders and subfolder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-feature-class-from-folders-and/m-p/730226#M56648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Updated: I have a sample with which you can delete it from the directory or dataset, but it does not work subdirectory&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Import Python Modules&lt;/P&gt;&lt;P&gt;import arcgisscripting&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Create the geoprocessor object&lt;/P&gt;&lt;P&gt;gp = arcgisscripting.create(9.3)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Set Workspace to list feature classes&lt;/P&gt;&lt;P&gt;#gp.workspace = "C:/temp/kme1.mdb/fdkme"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Get Input Workspace as Argument&lt;/P&gt;&lt;P&gt;gp.workspace = gp.GetParameterAsText(0)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Get List of Feature Classes in Workspace&lt;/P&gt;&lt;P&gt;lstFCs = gp.ListFeatureClasses()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;print "\n"&lt;/P&gt;&lt;P&gt;gp.AddMessage("\n")&lt;/P&gt;&lt;P&gt;print "--------------------------------------------------"&lt;/P&gt;&lt;P&gt;#gp.AddMessage("--------------------------------------------------")&lt;/P&gt;&lt;P&gt;for fc in lstFCs:&lt;/P&gt;&lt;P&gt;&amp;nbsp; print "Processing " + fc&lt;/P&gt;&lt;P&gt;&amp;nbsp; gp.AddMessage("Processing " + fc)&lt;/P&gt;&lt;P&gt;&amp;nbsp; recCnt = int(gp.GetCount_management(fc).GetOutput(0))&lt;/P&gt;&lt;P&gt;&amp;nbsp; if recCnt == 0:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Empty - Deleting " + fc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage("Empty - Deleting " + fc)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.Delete_management(fc)&lt;/P&gt;&lt;P&gt;&amp;nbsp; else:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print str(recCnt) + " Records - Keeping " + fc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gp.AddMessage(str(recCnt) + " Records - Keeping " + fc)&lt;/P&gt;&lt;P&gt;print "--------------------------------------------------"&lt;/P&gt;&lt;P&gt;gp.AddMessage("--------------------------------------------------")&lt;/P&gt;&lt;P&gt;print "\n"&lt;/P&gt;&lt;P&gt;gp.AddMessage("\n")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2014 13:10:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-feature-class-from-folders-and/m-p/730226#M56648</guid>
      <dc:creator>RuBi</dc:creator>
      <dc:date>2014-10-01T13:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty feature class from folders and subfolder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-feature-class-from-folders-and/m-p/730227#M56649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry don't use glob, this is better:&lt;/P&gt;&lt;P&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000023000000" title="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000023000000"&gt;ArcGIS Help 10.1 (arcpy.da.walk)&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Oct 2014 13:12:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-feature-class-from-folders-and/m-p/730227#M56649</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2014-10-01T13:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty feature class from folders and subfolder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-feature-class-from-folders-and/m-p/730228#M56650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="kn" style="color: #0000ff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Or who can help combine the above-mentioned writings that the current script to obtain?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0000ff; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="kn" style="color: #0000ff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="kn" style="color: #0000ff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE&gt;&lt;SPAN class="kn" style="color: #0000ff;"&gt;import&lt;/SPAN&gt; &lt;SPAN class="nn"&gt;arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="kn" style="color: #0000ff;"&gt;import&lt;/SPAN&gt; &lt;SPAN class="nn"&gt;os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="n"&gt;workspace&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="s" style="color: #a31515;"&gt;"c:/data"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="n"&gt;feature_classes&lt;/SPAN&gt; &lt;SPAN class="o"&gt;=&lt;/SPAN&gt; &lt;SPAN class="p"&gt;[]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN class="k" style="color: #0000ff;"&gt;for&lt;/SPAN&gt; &lt;SPAN class="n"&gt;dirpath&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;dirnames&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;filenames&lt;/SPAN&gt; &lt;SPAN class="ow" style="color: #0000ff;"&gt;in&lt;/SPAN&gt; &lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;da&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;Walk&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;workspace&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="n"&gt;datatype&lt;/SPAN&gt;&lt;SPAN class="o"&gt;=&lt;/SPAN&gt;&lt;SPAN class="s" style="color: #a31515;"&gt;"FeatureClass"&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="nb"&gt;type&lt;/SPAN&gt;&lt;SPAN class="o"&gt;=&lt;/SPAN&gt;&lt;SPAN class="s" style="color: #a31515;"&gt;"Polygon"&lt;/SPAN&gt;&lt;SPAN class="p"&gt;):&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="k" style="color: #0000ff;"&gt;for&lt;/SPAN&gt; &lt;SPAN class="n"&gt;filename&lt;/SPAN&gt; &lt;SPAN class="ow" style="color: #0000ff;"&gt;in&lt;/SPAN&gt; &lt;SPAN class="n"&gt;filenames&lt;/SPAN&gt;&lt;SPAN class="p"&gt;:&lt;/SPAN&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN class="n"&gt;feature_classes&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;append&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;os&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;path&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;join&lt;/SPAN&gt;&lt;SPAN class="p"&gt;(&lt;/SPAN&gt;&lt;SPAN class="n"&gt;dirpath&lt;/SPAN&gt;&lt;SPAN class="p"&gt;,&lt;/SPAN&gt; &lt;SPAN class="n"&gt;filename&lt;/SPAN&gt;&lt;SPAN class="p"&gt;))&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 13:18:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-feature-class-from-folders-and/m-p/730228#M56650</guid>
      <dc:creator>RuBi</dc:creator>
      <dc:date>2014-10-06T13:18:36Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty feature class from folders and subfolder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-feature-class-from-folders-and/m-p/730229#M56651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not sure what you're looking to do, but you need to indent the final line in your code above. This does nothing to delete empty shapefiles, though. Also would advise against using arcgisscripting; that's an older method. Not even sure if it would work to combine it with current arcpy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might also look at &lt;A href="https://docs.python.org/2/library/os.path.html" title="https://docs.python.org/2/library/os.path.html"&gt;10.1. os.path — Common pathname manipulations — Python 2.7.8 documentation&lt;/A&gt; and &lt;A href="https://docs.python.org/2/library/os.html#module-os" title="https://docs.python.org/2/library/os.html#module-os"&gt;15.1. os — Miscellaneous operating system interfaces — Python 2.7.8 documentation&lt;/A&gt; or &lt;A href="http://www.tutorialspoint.com/python/os_listdir.htm" title="http://www.tutorialspoint.com/python/os_listdir.htm"&gt;Python os.listdir() Method&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Oct 2014 13:33:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-feature-class-from-folders-and/m-p/730229#M56651</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-10-06T13:33:08Z</dc:date>
    </item>
  </channel>
</rss>

