<?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 multiple files in python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681752#M52808</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;I think Jake offered the right solution .....&lt;/P&gt;&lt;P&gt;You could change '1405' in '%_1405' to get all fc with 1405 in the name&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Aug 2014 12:52:54 GMT</pubDate>
    <dc:creator>JohannesBierer</dc:creator>
    <dc:date>2014-08-13T12:52:54Z</dc:date>
    <item>
      <title>delete multiple files in python</title>
      <link>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681749#M52805</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Users,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sure I have done this before but cannot recall how to do it. I would like to delete multiple feature classes using python but only files that have a suffix of say '1405' or '1305' for example. The main file name would be different e.g. 'NorthernWells_1405' &amp;amp; SouthernWells_1405' so use the suffix in the code to find these files and remove them.&lt;/P&gt;&lt;P&gt;In addition to this I would also like to rename files with a suffix like '1406' but again have a different file name.&lt;/P&gt;&lt;P&gt;Has anyone written some python code like this?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any assistance would be much appreciated,&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Aug 2014 09:44:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681749#M52805</guid>
      <dc:creator>ChrisGraves1</dc:creator>
      <dc:date>2014-08-13T09:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: delete multiple files in python</title>
      <link>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681750#M52806</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;import os&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Set the workspace for the ListFeatureClass function&lt;/P&gt;&lt;P&gt;#&lt;/P&gt;&lt;P&gt;env.workspace = "c:/Temp1"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Use the ListFeatureClasses function to return a list of &lt;/P&gt;&lt;P&gt;#&amp;nbsp; shapefiles.&lt;/P&gt;&lt;P&gt;#&lt;/P&gt;&lt;P&gt;fcList = arcpy.ListFeatureClasses()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;for fc in fcList:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fc&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fc == "herkunft.shp":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(fc)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Aug 2014 10:08:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681750#M52806</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2014-08-13T10:08:13Z</dc:date>
    </item>
    <item>
      <title>Re: delete multiple files in python</title>
      <link>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681751#M52807</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The below code will delete feature classes from the 'test.gdb' that contain '1405' or '1305'.&amp;nbsp; It will also rename any feature class that contains '1406' to text before the underscore.&amp;nbsp; For example, 'SouthernWells_1406' would be renamed to 'SouthernWells'.&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_14079282638865283" jivemacro_uid="_14079282638865283"&gt;
&lt;P&gt;import arcpy&lt;/P&gt;
&lt;P&gt;from arcpy import env&lt;/P&gt;
&lt;P&gt;env.workspace = r"C:\temp\python\test.gdb"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;for fc in arcpy.ListFeatureClasses("*"):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if '1405' in fc or '1305' in fc:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(fc)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif '1406' in fc:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Rename_management(fc, fc.split("_")[0])&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Aug 2014 11:11:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681751#M52807</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2014-08-13T11:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: delete multiple files in python</title>
      <link>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681752#M52808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;I think Jake offered the right solution .....&lt;/P&gt;&lt;P&gt;You could change '1405' in '%_1405' to get all fc with 1405 in the name&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Aug 2014 12:52:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681752#M52808</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2014-08-13T12:52:54Z</dc:date>
    </item>
    <item>
      <title>Re: delete multiple files in python</title>
      <link>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681753#M52809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thankyou very much for your help with this. I have got it working thankyou. I would also like to rename files and give them a suffix of _1406 for example. The existing file names are all different so they would need to stay the same.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again very much appreciated.&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Aug 2014 03:30:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681753#M52809</guid>
      <dc:creator>ChrisGraves1</dc:creator>
      <dc:date>2014-08-14T03:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: delete multiple files in python</title>
      <link>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681754#M52810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will just need to use the Rename function to do this.&amp;nbsp; Ex:&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_14080133461285177" jivemacro_uid="_14080133461285177"&gt;
&lt;P&gt;for fc in arcpy.ListFeatureClasses("*"): &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if &amp;lt;some criteria&amp;gt; in fc: &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Rename_management(fc, fc + "_1406")&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Aug 2014 10:49:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681754#M52810</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2014-08-14T10:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: delete multiple files in python</title>
      <link>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681755#M52811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks again Jake for your help really appreciate it. Hopefully soon I can repay you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Have a nice weekend.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;BR /&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Aug 2014 07:50:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681755#M52811</guid>
      <dc:creator>ChrisGraves1</dc:creator>
      <dc:date>2014-08-15T07:50:16Z</dc:date>
    </item>
    <item>
      <title>Re: delete multiple files in python</title>
      <link>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681756#M52812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have a chance, be sure to mark this thread as 'Answered' to help other users in the community.&amp;nbsp; Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Aug 2014 11:08:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/delete-multiple-files-in-python/m-p/681756#M52812</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2014-08-15T11:08:37Z</dc:date>
    </item>
  </channel>
</rss>

