<?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: search in folders and .gdb and rename featureclass part 2 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350598#M27507</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;looking at this i think i know what wrong but i do not know how to solve it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the Rename_management in my script do's not know from what .gdb the feature name i use is from.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;greetings Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Jan 2015 10:18:42 GMT</pubDate>
    <dc:creator>PeterVersteeg</dc:creator>
    <dc:date>2015-01-19T10:18:42Z</dc:date>
    <item>
      <title>search in folders and .gdb and rename featureclass part 2</title>
      <link>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350593#M27502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the end off part 1 i am able to search folders and Gdb's for featureclasses. for the next part i want to rename a feature in the "feature_class" list.so far i have this:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os&amp;nbsp; 
import arcpy&amp;nbsp; 


workspace = "D:\GIS\Zone1\Zone1A"
datatypes = "FeatureClass"
arcpy.env.overwriteOutput = True


def inventory_data(workspace, datatypes):&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for path, path_names, data_names in arcpy.da.Walk(&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; workspace, datatype=datatypes, type="Polygon"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for data_name in data_names:&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 os.path.join(path, data_name)&amp;nbsp; 
&amp;nbsp; 
for feature_class in inventory_data(workspace, "FeatureClass"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print feature_class
&amp;nbsp;&amp;nbsp;&amp;nbsp; if feature_class == "RenameTest":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Rename_management("RenameTes2", "RenameTest2")
print feature_class&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;can sameone point to me were i am going wrong.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thank you and greetings Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:29:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350593#M27502</guid>
      <dc:creator>PeterVersteeg</dc:creator>
      <dc:date>2021-12-11T16:29:12Z</dc:date>
    </item>
    <item>
      <title>Re: search in folders and .gdb and rename featureclass part 2</title>
      <link>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350594#M27503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you be more specific about what's "going wrong" - what's your problem, do you get any error messages, etc...? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The 2nd example in the &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000056000000"&gt;Help&lt;/A&gt; is quite useful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jan 2015 01:18:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350594#M27503</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2015-01-19T01:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: search in folders and .gdb and rename featureclass part 2</title>
      <link>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350595#M27504</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="text-align: left;"&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;I am not sure the function return any list that can be used by the for statement.&lt;/P&gt;&lt;P style="text-align: left;"&gt;Check the examples here: &lt;A href="http://resources.arcgis.com/en/help/main/10.2/002z/002z00000011000000.htm"&gt;http://resources.arcgis.com/en/help/main/10.2/002z/002z00000011000000.htm&lt;/A&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;The last few examples are very close to what you need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="text-align: left;"&gt;Have fun&lt;/P&gt;&lt;P style="text-align: left;"&gt;Mody&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jan 2015 06:36:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350595#M27504</guid>
      <dc:creator>ModyBuchbinder</dc:creator>
      <dc:date>2015-01-19T06:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: search in folders and .gdb and rename featureclass part 2</title>
      <link>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350596#M27505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;yes it is but my input for the rename is in a list. the search is ok i got the right list but the rename is not working. i do not have a error&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jan 2015 09:21:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350596#M27505</guid>
      <dc:creator>PeterVersteeg</dc:creator>
      <dc:date>2015-01-19T09:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: search in folders and .gdb and rename featureclass part 2</title>
      <link>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350597#M27506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My first script got me the featureclasses with there path, this is not what i want for my rename. now i got this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os


workspace = "D:\GIS\ZOne1\Zone1A"
feature_classes = []
walk = arcpy.da.Walk(workspace, datatype="FeatureClass", type="Polygon")


for dirpath, dirnames, filenames in walk:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feature_classes.append(os.path.join(dirpath, filename))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print filename


for fc in filename:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fc == "featureclassName":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Rename_management("featureclassName", "featureclassName_renameTest")
&amp;nbsp;&amp;nbsp;&amp;nbsp; elif fc == "feature




&lt;/PRE&gt;&lt;P&gt;&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; elif fc == "featureclassName1":&lt;/P&gt;&lt;P&gt;&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; arcpy.Rename_management("featureclassName1", "featureclassName1_renameTest")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(sorry samehow i cannot add more line to the script)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the print on line 13 gives me a list of all featureclasses i want to rename. but my rename is not working i do not get a error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;greetings Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:29:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350597#M27506</guid>
      <dc:creator>PeterVersteeg</dc:creator>
      <dc:date>2021-12-11T16:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: search in folders and .gdb and rename featureclass part 2</title>
      <link>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350598#M27507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;looking at this i think i know what wrong but i do not know how to solve it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the Rename_management in my script do's not know from what .gdb the feature name i use is from.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;greetings Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jan 2015 10:18:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350598#M27507</guid>
      <dc:creator>PeterVersteeg</dc:creator>
      <dc:date>2015-01-19T10:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: search in folders and .gdb and rename featureclass part 2</title>
      <link>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350599#M27508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is not necessary to create a double loop, but to provide a sample that does not have that much changed see the script below.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I introduced a dictionary "dct" holding the input name and the output name as key, value pair&lt;/LI&gt;&lt;LI&gt;in the second loop the fc is split into the workspace and the featureclass name&lt;/LI&gt;&lt;LI&gt;if the old name is in the dictionary (in the keys) then it is renamed&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os

workspace = "D:\GIS\ZOne1\Zone1A"
feature_classes = []
walk = arcpy.da.Walk(workspace, datatype="FeatureClass", type="Polygon")

dct = {'featureclassName': 'featureclassName_renameTest',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'featureclassName1': 'featureclassName1_renameTest',
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'another input name': 'corresponding output name'}

for dirpath, dirnames, filenames in walk:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for filename in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; feature_classes.append(os.path.join(dirpath, filename))

for fc in feature_classes:
&amp;nbsp;&amp;nbsp;&amp;nbsp; fc_ws, fc_name = os.path.split(fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fc_name in dct:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Rename_management(fc, os.path.join(fc_ws, dct[fc_name]))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:29:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350599#M27508</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T16:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: search in folders and .gdb and rename featureclass part 2</title>
      <link>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350600#M27509</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to learn arcpy (python) and was looking for a project i can use at work. Perhaps this was a bit to much for now but i am analyzing your script and reading about the parts i do not understand yet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script works great and i even understand 80% off the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Greetings Peter&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Jan 2015 13:34:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/search-in-folders-and-gdb-and-rename-featureclass/m-p/350600#M27509</guid>
      <dc:creator>PeterVersteeg</dc:creator>
      <dc:date>2015-01-19T13:34:10Z</dc:date>
    </item>
  </channel>
</rss>

