<?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: arcpy.CopyFeatures_management failing in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340366#M26717</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem with this is it does not access the sub directories. So it does not work. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 09 Feb 2015 14:40:07 GMT</pubDate>
    <dc:creator>DanielErklauer</dc:creator>
    <dc:date>2015-02-09T14:40:07Z</dc:date>
    <item>
      <title>arcpy.CopyFeatures_management failing</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340360#M26711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I am having an issue with using arcpy.CopyFeatures_management.&amp;nbsp; I am attempting to copy shape files from a temp directory and write them to a database as feature classes.&amp;nbsp; What is wrong with this code? My print function correctly lists all of the shape files in the temp directory however It then writes one shape to my database directory and gives it the database name. &lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from arcpy import env
import os
import sys
arcpy.env.overwriteOutput = True
workspace = "S:\\xxx\\GIS\\"
feature_classes = []
walk = arcpy.da.Walk(workspace, datatype="FeatureClass", type="FeatureClass")
outWorkspace = "S:\\xxx\\xxx\\xxx.gdb"
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))
print feature_classes
for filename in feature_classes:
&amp;nbsp;&amp;nbsp;&amp;nbsp; outFeatureClass = os.path.join(outWorkspace, filename.strip(".shp"))
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(filename, outWorkspace)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:06:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340360#M26711</guid>
      <dc:creator>DanielErklauer</dc:creator>
      <dc:date>2021-12-11T16:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.CopyFeatures_management failing</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340361#M26712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Where is this variable used in your last loop?&amp;nbsp; outFeatureClass&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Feb 2015 23:44:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340361#M26712</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-02-05T23:44:00Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.CopyFeatures_management failing</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340362#M26713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is line 7. I print it a few lines down to confirm it picked up all the&lt;/P&gt;&lt;P&gt;shape files.   The loop is intended to strip the directories and .shp for&lt;/P&gt;&lt;P&gt;conversion.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 00:09:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340362#M26713</guid>
      <dc:creator>DanielErklauer</dc:creator>
      <dc:date>2015-02-06T00:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.CopyFeatures_management failing</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340363#M26714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I thought that maybe you wanted outFeatureClass in line 16 in place of outWorkspace as in &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/Copy_Features/001700000035000000/"&gt;example 2 &lt;/A&gt;in the help &lt;SPAN style="line-height: 1.5;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 00:15:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340363#M26714</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2015-02-06T00:15:22Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.CopyFeatures_management failing</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340364#M26715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That could be it thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Feb 2015 00:20:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340364#M26715</guid>
      <dc:creator>DanielErklauer</dc:creator>
      <dc:date>2015-02-06T00:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.CopyFeatures_management failing</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340365#M26716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is how I would do that. Hope it helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import os


in_path = r'C:\xxx\xxx\shp'
out_path = r'C:\xxx\xxx\out.gdb'


arcpy.env.workspace = in_path
arcpy.env.overwriteOutput = True


shapefiles = arcpy.ListFeatureClasses()


for shapefile in shapefiles:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'copying: ' + shapefile[:-4]
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(shapefile, os.path.join(out_path, shapefile[:-4]))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:06:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340365#M26716</guid>
      <dc:creator>forestknutsen1</dc:creator>
      <dc:date>2021-12-11T16:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.CopyFeatures_management failing</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340366#M26717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problem with this is it does not access the sub directories. So it does not work. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 14:40:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340366#M26717</guid>
      <dc:creator>DanielErklauer</dc:creator>
      <dc:date>2015-02-09T14:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.CopyFeatures_management failing</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340367#M26718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could put your particular subdirectories in a list. Then you could add the shapefile copy loop code that &lt;A href="https://community.esri.com/migrated-users/26633" target="_blank"&gt;forest knutsen&lt;/A&gt; wrote inside a loop that iterates through the subdirectory list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;rootdir = r"C:\xxx\xxx\shp"

subfolders = [
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Folder1",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "Another Folder",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "AndAnother",
]

for folder in myfolders:
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;arcpy.env.workspace = os.path.join(rootdir, folder)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for shapefile in arcpy.ListFeatureClasses():
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'copying: ' + shapefile[:-4]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(shapefile, os.path.join(out_path, shapefile[:-4]))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or you could utilize Python's own &lt;A href="http://www.tutorialspoint.com/python/os_walk.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;os.walk()&lt;/A&gt; to navigate your folders instead of listing them out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:06:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340367#M26718</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-12-11T16:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.CopyFeatures_management failing</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340368#M26719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So there is nothing I can do with this&amp;nbsp; arcpy.da.Walk(workspace, datatype=&lt;SPAN class="string"&gt;"FeatureClass"&lt;/SPAN&gt;, type=&lt;SPAN class="string"&gt;"FeatureClass"&lt;/SPAN&gt;)&amp;nbsp;&amp;nbsp; which is able to find all of the shapefiles in the sundirectories?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 16:16:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340368#M26719</guid>
      <dc:creator>DanielErklauer</dc:creator>
      <dc:date>2015-02-09T16:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.CopyFeatures_management failing</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340369#M26720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, you're correct, &lt;A href="http://resources.arcgis.com/en/help/main/10.2/018w/018w00000023000000.htm"&gt;arcpy.da.Walk()&lt;/A&gt; would probably be the best thing to use. I am so used to using it just in a geodatabase that I forgot that it listed folders too.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 16:20:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340369#M26720</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-02-09T16:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.CopyFeatures_management failing</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340370#M26721</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@Blake do you have any insight on why my for statements are not working using my the variable?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 17:09:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340370#M26721</guid>
      <dc:creator>DanielErklauer</dc:creator>
      <dc:date>2015-02-09T17:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.CopyFeatures_management failing</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340371#M26722</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I apologize &lt;A href="https://community.esri.com/migrated-users/28780"&gt;Daniel Erklauer&lt;/A&gt;‌, I did not read your first post well and was going off what &lt;A href="https://community.esri.com/migrated-users/26633"&gt;forest knutsen&lt;/A&gt;‌ posted. I have not tried testing any of this yet, but you may have to use a conversion (like &lt;A href="http://resources.arcgis.com/en/help/main/10.2/0012/001200000020000000.htm"&gt;feature class to feature class&lt;/A&gt;) instead of copy features. Or better yet, maybe you could pass your whole list of shapefiles into &lt;A href="http://resources.arcgis.com/en/help/main/10.2/0012/001200000021000000.htm"&gt;feature class to getodatabase&lt;/A&gt; for a batch load.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Feb 2015 17:21:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-copyfeatures-management-failing/m-p/340371#M26722</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-02-09T17:21:02Z</dc:date>
    </item>
  </channel>
</rss>

