<?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 Output name to be the same as the input name (in a new folder) after processing in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/output-name-to-be-the-same-as-the-input-name-in-a/m-p/624527#M20664</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;I was following this simple example from ESRI (&lt;A href="http://help.arcgis.com/EN/arcgisdesktop/10.0/help/index.html#/Using_functions_in_Python/002z0000000m000000/" title="http://help.arcgis.com/EN/arcgisdesktop/10.0/help/index.html#/Using_functions_in_Python/002z0000000m000000/"&gt;ArcGIS Desktop&lt;/A&gt; &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&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;# The workspace environment needs to be set before ListFeatureClasses&lt;/P&gt;&lt;P&gt;# to identify which workspace the list will be based on&lt;/P&gt;&lt;P&gt;env.workspace = "c:/data"&lt;/P&gt;&lt;P&gt;out_workspace = "c:/data/results/"&lt;/P&gt;&lt;P&gt;clip_features = "c:/data/testarea/boundary.shp"&lt;/P&gt;&lt;P&gt;# Loop through a list of feature classes in the workspace&lt;/P&gt;&lt;P&gt;for fc in arcpy.ListFeatureClasses():&lt;/P&gt;&lt;P&gt;&amp;nbsp; # Set the output name to be the same as the input name, and &lt;/P&gt;&lt;P&gt;&amp;nbsp; # locate in the 'out_workspace' workspace&lt;/P&gt;&lt;P&gt;&amp;nbsp; #&lt;/P&gt;&lt;P&gt;&amp;nbsp; output = os.path.join(out_workspace, fc)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # Clip each input feature class in the list&lt;/P&gt;&lt;P&gt;&amp;nbsp; #&lt;/P&gt;&lt;P&gt;&amp;nbsp; arcpy.Clip_analysis(fc, clip_features, output, 0.1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to run a very similar code with "Identity_analysis", however, I receive an error message when run my code, as it wants to create only one shapefile rather many with the same name(s)&amp;nbsp; as the input file(s). Here is the code. It generates only one file " identity_country.shp" and than gives me an error msg that the file already exist.&lt;/P&gt;&lt;P&gt;&lt;/P&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;dirpath = r'C:\reggie\stat\spatial'&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = dirpath&lt;/P&gt;&lt;P&gt;#set local parameters&lt;/P&gt;&lt;P&gt;identity_feature = r'C:\reggie\stat\GIS_stats\country.shp'&lt;/P&gt;&lt;P&gt;out_workspace = r'C:\reggie\stat\spatial\identity_country'&lt;/P&gt;&lt;P&gt;for fc in arcpy.ListFeatureClasses("*"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output = os.path.join(out_workspace, fc)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Identity_analysis(fc, identity_feature, output, "ALL", "", "NO_RELATIONSHIPS")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 01 Sep 2015 14:42:36 GMT</pubDate>
    <dc:creator>ErtTre</dc:creator>
    <dc:date>2015-09-01T14:42:36Z</dc:date>
    <item>
      <title>Output name to be the same as the input name (in a new folder) after processing</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/output-name-to-be-the-same-as-the-input-name-in-a/m-p/624527#M20664</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;I was following this simple example from ESRI (&lt;A href="http://help.arcgis.com/EN/arcgisdesktop/10.0/help/index.html#/Using_functions_in_Python/002z0000000m000000/" title="http://help.arcgis.com/EN/arcgisdesktop/10.0/help/index.html#/Using_functions_in_Python/002z0000000m000000/"&gt;ArcGIS Desktop&lt;/A&gt; &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&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;# The workspace environment needs to be set before ListFeatureClasses&lt;/P&gt;&lt;P&gt;# to identify which workspace the list will be based on&lt;/P&gt;&lt;P&gt;env.workspace = "c:/data"&lt;/P&gt;&lt;P&gt;out_workspace = "c:/data/results/"&lt;/P&gt;&lt;P&gt;clip_features = "c:/data/testarea/boundary.shp"&lt;/P&gt;&lt;P&gt;# Loop through a list of feature classes in the workspace&lt;/P&gt;&lt;P&gt;for fc in arcpy.ListFeatureClasses():&lt;/P&gt;&lt;P&gt;&amp;nbsp; # Set the output name to be the same as the input name, and &lt;/P&gt;&lt;P&gt;&amp;nbsp; # locate in the 'out_workspace' workspace&lt;/P&gt;&lt;P&gt;&amp;nbsp; #&lt;/P&gt;&lt;P&gt;&amp;nbsp; output = os.path.join(out_workspace, fc)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; # Clip each input feature class in the list&lt;/P&gt;&lt;P&gt;&amp;nbsp; #&lt;/P&gt;&lt;P&gt;&amp;nbsp; arcpy.Clip_analysis(fc, clip_features, output, 0.1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to run a very similar code with "Identity_analysis", however, I receive an error message when run my code, as it wants to create only one shapefile rather many with the same name(s)&amp;nbsp; as the input file(s). Here is the code. It generates only one file " identity_country.shp" and than gives me an error msg that the file already exist.&lt;/P&gt;&lt;P&gt;&lt;/P&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;dirpath = r'C:\reggie\stat\spatial'&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = dirpath&lt;/P&gt;&lt;P&gt;#set local parameters&lt;/P&gt;&lt;P&gt;identity_feature = r'C:\reggie\stat\GIS_stats\country.shp'&lt;/P&gt;&lt;P&gt;out_workspace = r'C:\reggie\stat\spatial\identity_country'&lt;/P&gt;&lt;P&gt;for fc in arcpy.ListFeatureClasses("*"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output = os.path.join(out_workspace, fc)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Identity_analysis(fc, identity_feature, output, "ALL", "", "NO_RELATIONSHIPS")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Sep 2015 14:42:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/output-name-to-be-the-same-as-the-input-name-in-a/m-p/624527#M20664</guid>
      <dc:creator>ErtTre</dc:creator>
      <dc:date>2015-09-01T14:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: Output name to be the same as the input name (in a new folder) after processing</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/output-name-to-be-the-same-as-the-input-name-in-a/m-p/624528#M20665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does your output shapefile already exists in your output folder? If yes, then you would need to set the overwrite property to True or use python logic to check if the output shapefile exists and delete it if does prior to calling the tool that will generate it. I've shown two options for this below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# ## OPTION A ## #
import arcpy
from os import path
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r"C:\reggie\stats\spatial"
idFeat = r""
outWS&amp;nbsp; = r""
for fc in arcpy.ListFeatureClasses():
&amp;nbsp;&amp;nbsp;&amp;nbsp; output = path.join(outWS, fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.analysis.Identity(fc, idFeat, output, relationship="NO_RELATIONSHIPS")

# ## OPTION B ## #&amp;nbsp;&amp;nbsp;&amp;nbsp; 
import arcpy
from os import path
arcpy.env.workspace = r"C:\reggie\stats\spatial"
idFeat = r""
outWS&amp;nbsp; = r""
for fc in arcpy.ListFeatureClasses():
&amp;nbsp;&amp;nbsp;&amp;nbsp; output = path.join(outWS, fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(output): 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.management.Delete(output)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.analysis.Identity(fc, idFeat, output, relationship="NO_RELATIONSHIPS")&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:36:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/output-name-to-be-the-same-as-the-input-name-in-a/m-p/624528#M20665</guid>
      <dc:creator>FreddieGibson</dc:creator>
      <dc:date>2021-12-12T02:36:01Z</dc:date>
    </item>
    <item>
      <title>Re: Output name to be the same as the input name (in a new folder) after processing</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/output-name-to-be-the-same-as-the-input-name-in-a/m-p/624529#M20666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Freddie,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Both worked like charm, million thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Additional Q - as the input vector contains many polygons while the identify feature has only one polygon, however, when the identify feature crosses the input feature I receive two or more readings (with the same FID) . See it below:&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/125079_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;Could I set up the code in a way, that the input polygon is either and only in or out of the identify feature but not in both? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Sep 2015 15:32:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/output-name-to-be-the-same-as-the-input-name-in-a/m-p/624529#M20666</guid>
      <dc:creator>ErtTre</dc:creator>
      <dc:date>2015-09-03T15:32:50Z</dc:date>
    </item>
  </channel>
</rss>

