<?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: Delete all empty shapefiles in a Folder in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165101#M12672</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Riyas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This time it gets stuck at the MakeFeatureLayer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 000732: Input Features: Dataset GISTRAN.SubstationCOOROW, SHIRE OF.shp does not exist or is not supported&lt;/P&gt;&lt;P&gt;Failed to execute (MakeFeatureLayer).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 26 Sep 2014 00:38:47 GMT</pubDate>
    <dc:creator>MittRamgobin</dc:creator>
    <dc:date>2014-09-26T00:38:47Z</dc:date>
    <item>
      <title>Delete all empty shapefiles in a Folder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165097#M12668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I want to delete all empty shapefiles in a folder. The following is not working:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="python" name="code"&gt; #Find empty shapefiles and delete them&amp;nbsp;&amp;nbsp; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;DIV class="bar"&gt;&lt;P&gt;arcpy.env.workspace = r&lt;SPAN class="string"&gt;"S:\SupportServices\LGAShapefiles"&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;shapefiles = arcpy.ListFeatureClasses()&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;for shapefile &lt;SPAN class="keyword"&gt;in&lt;/SPAN&gt; shapefiles:&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;if arcpy.management.GetCount(shapefile)[&lt;SPAN class="number"&gt;0&lt;/SPAN&gt;]==&lt;SPAN class="string"&gt;"0"&lt;/SPAN&gt;:&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(shapefile)&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN class="keyword"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print shapefile + &lt;SPAN class="string"&gt;"Deleted"&lt;/SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 09:06:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165097#M12668</guid>
      <dc:creator>MittRamgobin</dc:creator>
      <dc:date>2014-09-25T09:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty shapefiles in a Folder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165098#M12669</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mitt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should be &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if int(arcpy.GetCount_management(&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 13.3333339691162px;"&gt;shapefile&lt;/SPAN&gt;).getOutput(0)) == 0:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;have a look at example 2 &lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000n7000000" title="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//0017000000n7000000"&gt;ArcGIS Desktop&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 09:51:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165098#M12669</guid>
      <dc:creator>RiyasDeen</dc:creator>
      <dc:date>2014-09-25T09:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty shapefiles in a Folder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165099#M12670</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Riyas,&lt;/P&gt;&lt;P&gt;Thank you for your input.&lt;/P&gt;&lt;P&gt;I am now getting the following error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ExecuteError: Failed to execute. Parameters are not valid.&lt;/P&gt;&lt;P&gt;ERROR 000732: Input Rows: Dataset GISTRAN.SubstationCOOROW, SHIRE OF.shp does not exist or is not supported&lt;/P&gt;&lt;P&gt;Failed to execute (GetCount).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is going on?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Sep 2014 23:57:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165099#M12670</guid>
      <dc:creator>MittRamgobin</dc:creator>
      <dc:date>2014-09-25T23:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty shapefiles in a Folder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165100#M12671</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mitt,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry, Get Count accepts a layer input. We need to create a layer from the shapefile and pass it as input to the get count tool. Use below code, tested. Mind the line intents&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14116907264803108" jivemacro_uid="_14116907264803108"&gt;
&lt;P&gt;arcpy.env.workspace = r"C:\tempdelete\Test_road" &lt;/P&gt;
&lt;P&gt;shapefiles = arcpy.ListFeatureClasses() &lt;/P&gt;
&lt;P&gt;for shapefile in shapefiles:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; layerName = arcpy.Describe(shapefile).baseName&lt;/P&gt;
&lt;P&gt;&amp;nbsp; arcpy.AddMessage(layerName)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; arcpy.MakeFeatureLayer_management (shapefile, layerName)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; arcpy.AddMessage(arcpy.GetCount_management(layerName).getOutput(0))&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; if int(arcpy.GetCount_management(layerName).getOutput(0)) == 0:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; arcpy.Delete_management(shapefile)&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2014 00:19:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165100#M12671</guid>
      <dc:creator>RiyasDeen</dc:creator>
      <dc:date>2014-09-26T00:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty shapefiles in a Folder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165101#M12672</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Riyas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This time it gets stuck at the MakeFeatureLayer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ERROR 000732: Input Features: Dataset GISTRAN.SubstationCOOROW, SHIRE OF.shp does not exist or is not supported&lt;/P&gt;&lt;P&gt;Failed to execute (MakeFeatureLayer).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2014 00:38:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165101#M12672</guid>
      <dc:creator>MittRamgobin</dc:creator>
      <dc:date>2014-09-26T00:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty shapefiles in a Folder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165102#M12673</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import arcpy
import sys
import os


# Script to create LGA Map with WP Infrastructure


# Define variables


arcpy.env.workspace = r"C:\Users\N041871\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde"
arcpy.env.overwriteOutput = True
#LGA = arcpy.GetParameterAsText(0) # Input Required Local Government Area
LGA ="COOROW, SHIRE OF"


#Define Layers to Intersect


#1. Transmission Layers
T330OH = r"C:\Users\N041871\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde\GISTRAN.Transmission\GISTRAN.Trans_330kV_OH_Carrier"&amp;nbsp;&amp;nbsp;&amp;nbsp; 
T330UG = r"C:\Users\N041871\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde\GISTRAN.Transmission\GISTRAN.Trans_330kV_UG_Cable"
T220OV = r"C:\Users\N041871\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde\GISTRAN.Transmission\GISTRAN.Trans_220kV_OH_Carrier"
T132OH = r"C:\Users\N041871\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde\GISTRAN.Transmission\GISTRAN.Trans_132kV_OH_Carrier"
T132UG = r"C:\Users\N041871\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde\GISTRAN.Transmission\GISTRAN.Trans_132kV_UG_Cable"
T66OV = r"C:\Users\N041871\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde\GISTRAN.Transmission\GISTRAN.Trans_66kV_OH_Carrier"
T66UG = r"C:\Users\N041871\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde\GISTRAN.Transmission\GISTRAN.Trans_66kV_UG_Cable"
T33OH = r"C:\Users\N041871\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde\GISTRAN.Transmission\GISTRAN.Trans_33kV_OH_Carrier"
T33UG = r"C:\Users\N041871\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde\GISTRAN.Transmission\GISTRAN.Trans_33kV_UG_Cable"
TransStruc = r"C:\Users\N041871\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde\GISTRAN.Transmission\GISTRAN.Trans_Structure"
Substation = r"C:\Users\N041871\AppData\Roaming\ESRI\Desktop10.0\ArcCatalog\DynamicCredentials@GISR.sde\GISTRAN.Transmission\GISTRAN.Substation"
#Group Transmission Values:
Transmission = (T330OH, T330UG, T220OV, T132OH, T132UG, T66OV, T66UG, T33OH, T33UG, TransStruc, Substation)
 
#2. Distrubution Layers
POLES = os.path.join("ARCFM.Structure", "ARCFM.Pole")
HVOH = os.path.join("ARCFM.Distribution_HV", "ARCFM.Conductor_HV")
HVUG = os.path.join("ARCFM.Distribution_HV", "ARCFM.Cable_HV")
LVOH = os.path.join("ARCFM.Distribution_LV", "ARCFM.Conductor_LV")
LVUG = os.path.join("ARCFM.Distribution_LV", "ARCFM.Cable_LV")
#Group Distribution Values
Distribution = (POLES, HVOH, HVUG, LVOH, LVUG)
&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
#Select Required LGA
arcpy.MakeFeatureLayer_management("GISEXT.Local_Government_Authority", "LGAlyr")
fieldName = "NAME"
Query = "\""+fieldName+"\"='"+LGA+"'"
arcpy.SelectLayerByAttribute_management ("LGAlyr", "NEW_SELECTION", Query)
###arcpy.SelectLayerByAttribute_management ("LGAlyr", "NEW_SELECTION", """ "NAME" = 'ALBANY, CITY OF' """) - working code


for Struc in Transmission:
&amp;nbsp;&amp;nbsp;&amp;nbsp; outputPath = r"S:\SupportServices\LGAShapefiles"
&amp;nbsp;&amp;nbsp;&amp;nbsp; basefileName = arcpy.Describe(Struc).baseName + LGA
&amp;nbsp;&amp;nbsp;&amp;nbsp; fileFormat= '.shp'
&amp;nbsp;&amp;nbsp;&amp;nbsp; finalDest = os.path.join(outputPath,basefileName+fileFormat)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_analysis(Struc, "LGAlyr",finalDest)
#arcpy.Clip_analysis(Struc,"LGAlyr", finalDest)
print "Transmission Shapefile Created"


##for Struc in Distribution:
##&amp;nbsp;&amp;nbsp;&amp;nbsp; outputPath = r"S:\SupportServices\LGAShapefiles"
##&amp;nbsp;&amp;nbsp;&amp;nbsp; basefileName = arcpy.Describe(Struc).baseName + LGA
##&amp;nbsp;&amp;nbsp;&amp;nbsp; fileFormat= '.shp'
##&amp;nbsp;&amp;nbsp;&amp;nbsp; finalDest = os.path.join(outputPath,basefileName+fileFormat)
##&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Clip_analysis(Struc, "LGAlyr",finalDest)





#Find empty shapefiles and delete them
arcpy.env.workspace = r"S:\SupportServices\LGAShapefiles"


shapefiles = arcpy.ListFeatureClasses()


for shapefile in shapefiles:
&amp;nbsp;&amp;nbsp;&amp;nbsp; layerName = arcpy.Describe(shapefile).baseName
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(layerName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management (shapefile, layerName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.GetCount_management(layerName).getOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp; if int(arcpy.GetCount_management(layerName).getOutput(0)) == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(shapefile)




&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 08:37:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165102#M12673</guid>
      <dc:creator>MittRamgobin</dc:creator>
      <dc:date>2021-12-11T08:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty shapefiles in a Folder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165103#M12674</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mitt,&lt;/P&gt;&lt;P&gt;It's the period character in your shapefile name that's creating the issue.&lt;/P&gt;&lt;P&gt;Change line 43 in above code to replace . with _&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: #000000; font-size: 12px; font-family: Consolas, 'Courier New', Courier, mono, serif;"&gt;basefileName = arcpy.Describe(Struc).baseName.replace('.','_') + LGA&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2014 01:03:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165103#M12674</guid>
      <dc:creator>RiyasDeen</dc:creator>
      <dc:date>2014-09-26T01:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty shapefiles in a Folder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165104#M12675</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Riyas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now there is this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ExecuteError: ERROR 000210: Cannot create output S:\SupportServices\LGAShapefiles\GISTRAN_Trans_330kV_OH_CarrierKONDININ, SHIRE OF.shp&lt;/P&gt;&lt;P&gt;ERROR 000354: The name contains invalid characters&lt;/P&gt;&lt;P&gt;Failed to execute (Clip).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2014 01:40:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165104#M12675</guid>
      <dc:creator>MittRamgobin</dc:creator>
      <dc:date>2014-09-26T01:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty shapefiles in a Folder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165105#M12676</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/laugh.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;, in your shapefile name is creating issue with clip. Interestingly if your shape file name is GISTRAN.Trans_330kV_OH_CarrierKONDININ, SHIRE OF.shp (with period) it's slipping through&lt;/P&gt;&lt;P&gt;. is creating issue with make feature layer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's better to avoid special characters in your shape file name all together.&lt;/P&gt;&lt;P&gt;Change your LGA name to Shire of KONDININ without , separator.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2014 01:58:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165105#M12676</guid>
      <dc:creator>RiyasDeen</dc:creator>
      <dc:date>2014-09-26T01:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty shapefiles in a Folder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165106#M12677</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Works like a treat now!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you Riyas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2014 03:33:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165106#M12677</guid>
      <dc:creator>MittRamgobin</dc:creator>
      <dc:date>2014-09-26T03:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty shapefiles in a Folder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165107#M12678</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try to delete shp files from Arc catalogue's catalogue tree.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2014 03:38:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/165107#M12678</guid>
      <dc:creator>LilaDevkota</dc:creator>
      <dc:date>2014-09-26T03:38:29Z</dc:date>
    </item>
    <item>
      <title>Re: Delete all empty shapefiles in a Folder</title>
      <link>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/1026193#M59927</link>
      <description>&lt;LI-CODE lang="markup"&gt;import arcpy, math, gc

# Workspace, overwrite 
arcpy.env.workspace = r"D:\testScript\My.gdb" 
arcpy.env.overwriteOutput = True

# INPUTS 
objects_input = r"D:\testScript\objects.shp" # must be polygons 
objects = "objects_lyr.shp" 
arcpy.MakeFeatureLayer_management(objects_input, objects)

# OUTPUTS, most temporal 
out_path=r"D:\testScript"
out_name="Hello.shp"
geometry_type = "POLYGON"
template = "study_quads.shp"
has_m = "DISABLED"
has_z = "DISABLED"
Myres = "Myres.shp"
arcpy.Delete_management(out_name) 
out_name_erase = "in_memory" + "\\" + "out_name_erase" 
polygon = "in_memory" + "\\" + "polygon" 
polygon_dissolve = "in_memory" + "\\" + "polygon_dissolve"
arcpy.CreateFeatureclass_management(out_path, out_name, geometry_type)

# Parameters 
distance = 18 # distance for move in direction 
direction = 360 # direction in degrees (90 is from north to south) 
index = 0

# Set UpdateCursor
cur_objects = arcpy.da.UpdateCursor(objects, ("Dir"))
for row_objects in cur_objects:
    try:
        fid = row_objects[0]
        sql = '"Dir" = ' + str(index)
        index += 1

        # Initialize lists
        lines_list = []
        lines_created = []

        # Select current feature
        arcpy.SelectLayerByAttribute_management(objects, "NEW_SELECTION", sql)
        vertexes = "in_memory" + "\\" + "vertexes"

        # Convert object to vertexes
        arcpy.FeatureVerticesToPoints_management(objects, vertexes, "ALL")
        index_vertex = 0

        # Set SearchCursor for vertexes
        cur_vertexes = arcpy.da.SearchCursor(vertexes, ("SHAPE@XY"))
        for row_vertexes in cur_vertexes:
            vertex_coords_x = row_vertexes[0][0]
            vertex_coords_y = row_vertexes[0][1]

            # Define points coordinates
            point_move_x = vertex_coords_x - (distance) * math.cos(math.radians(direction))
            point_move_y = vertex_coords_y - (distance) * math.cos(math.radians(90 - direction))

            # Make list of points
            new_line = ([[vertex_coords_x, vertex_coords_y], [point_move_x, point_move_y]])
            lines_list.append(new_line)

            # From second cycle
            if index_vertex &amp;gt; 0:
                lines_vertexes = ([[vertex_coords_x, vertex_coords_y], start_line])
                lines_ends = ([[point_move_x, point_move_y], end_line])
                lines_list.append(lines_vertexes)
                lines_list.append(lines_ends)
            start_line = [vertex_coords_x, vertex_coords_y]
            end_line = [point_move_x, point_move_y]
            index_vertex = index_vertex + 1

        # Cycle that makes polylines from points
        for lines_step in lines_list:
            lines_created.append(arcpy.Polyline(arcpy.Array([arcpy.Point(*sour) for sour in lines_step])))

        arcpy.FeatureToPolygon_management(lines_created, polygon)
        arcpy.AggregatePolygons_cartography(polygon, polygon_dissolve, 1)

        # Final editing
        arcpy.Erase_analysis(polygon_dissolve, objects, out_name_erase)
        arcpy.Append_management(out_name_erase, out_name, "NO_TEST")
        arcpy.Delete_management("in_memory")
        arcpy.Delete_management(vertexes)
        start_line = []

        # Clear selection, memory and deleting temps
        arcpy.SelectLayerByAttribute_management(objects, "CLEAR_SELECTION")
        print ("Object number: " + str(index - 1) + " -- done.")
        gc.collect()


    # Catch errors
    except Exception as e:
        pass
        print ("Error:")
        print (e)
        print ("\n")
        index += 1&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 12 Feb 2021 07:37:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-all-empty-shapefiles-in-a-folder/m-p/1026193#M59927</guid>
      <dc:creator>konstantBrr</dc:creator>
      <dc:date>2021-02-12T07:37:32Z</dc:date>
    </item>
  </channel>
</rss>

