<?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: Python - GetCount help in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-getcount-help/m-p/516583#M40532</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although you marked you question as solved already, let me add some additional information. You &lt;SPAN style="text-decoration: underline;"&gt;can&lt;/SPAN&gt; use a format statement inside the arcpy.AddMessage statement. I do it all the time and there is really no reason why you shouldn't. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do see some strange indenting in you code, which may be the reason for a possible error. Was there an error occurring? Look at the slightly changed code below (I commented the project and copy statements)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
template = arcpy.GetParameterAsText(0)
arcpy.env.workspace = arcpy.GetParameterAsText(1)
OutFolder = arcpy.GetParameterAsText(2)

# Get the spatial reference
spatialRef = arcpy.Describe(template).spatialReference.name

# create a list of featureclasses in the current workspace
fcList = arcpy.ListFeatureClasses()

#Loop through shapfiles in folder and reproject
for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcspatialRef = arcpy.Describe(fc).spatialReference.name
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fcspatialRef != spatialRef:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Projecting: {0}".format(fc))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # arcpy.Project_management(fc, os.path.join(outFolder , fc), template)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; process = "reprojected to"
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Copying: {0}".format(fc))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; process = "copied using"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # arcpy.CopyFeatures_management(fc, os.path.join(outFolder,fc))

&amp;nbsp;&amp;nbsp;&amp;nbsp; projCount = int(arcpy.GetCount_management(fc).getOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the count from GetCount's Result object
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("{0} features (not datasets) have been {3}: {1} and saved in {2}".format(projCount, spatialRef, OutFolder, process))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on the inputs selected, this produced the following output in the geoprocessing window.&lt;/P&gt;&lt;P&gt;In case the sr is different:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Executing: revisarmensajes D:\Xander\GeoNet\DistFireHouse\datatest\firehistory.shp D:\Xander\GeoNet\DistFireHouse\shp D:\Xander\GeoNet\DistFireHouse\test
Start Time: Thu Apr 16 06:50:31 2015
Running script revisarmensajes...
Projecting: firehistory_NAD_fips3002_feet.shp
636 features (not datasets) have been reprojected to: NAD_1983_UTM_Zone_13N and saved in D:\Xander\GeoNet\DistFireHouse\test
Projecting: housesaledata.shp
7204 features (not datasets) have been reprojected to: NAD_1983_UTM_Zone_13N and saved in D:\Xander\GeoNet\DistFireHouse\test
Completed script revisarmensajes...
Succeeded at Thu Apr 16 06:50:31 2015 (Elapsed Time: 0,08 seconds)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case the sr is the same:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Executing: revisarmensajes D:\Xander\GeoNet\DistFireHouse\shp\firehistory_NAD_fips3002_feet.shp D:\Xander\GeoNet\DistFireHouse\shp D:\Xander\GeoNet\DistFireHouse\test
Start Time: Thu Apr 16 06:51:17 2015
Running script revisarmensajes...
Copying: firehistory_NAD_fips3002_feet.shp
636 features (not datasets) have been copied to: NAD_1983_StatePlane_New_Mexico_Central_FIPS_3002_Feet and saved in D:\Xander\GeoNet\DistFireHouse\test
Copying: housesaledata.shp
7204 features (not datasets) have been copied to: NAD_1983_StatePlane_New_Mexico_Central_FIPS_3002_Feet and saved in D:\Xander\GeoNet\DistFireHouse\test
Completed script revisarmensajes...
Succeeded at Thu Apr 16 06:51:17 2015 (Elapsed Time: 0,08 seconds)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:32:58 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2021-12-11T22:32:58Z</dc:date>
    <item>
      <title>Python - GetCount help</title>
      <link>https://community.esri.com/t5/python-questions/python-getcount-help/m-p/516580#M40529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am having trouble getting the arcp.GetCount_management to print the GetCount arcpy.AddMessage in the geoprocessing dialog window;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Get the spatial reference
 spatialRef = arcpy.Describe(template).spatialReference.name
&amp;nbsp; 
#Loop through shapfiles in folder and reproject
 for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fcspatialRef = arcpy.Describe(fc).spatialReference.name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if fcspatialRef != spatialRef:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Project_management(fc, outFolder + "\\" + fc, template)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; projCount = int(arcpy.GetCount_management(fc).getOutput(0)) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(fc, outFolder + "\\" + fc)

&lt;SPAN style="color: #303030;"&gt;&lt;CODE&gt;&lt;SPAN class="com"&gt;# Get the count from GetCount's Result object&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("{0} datasets have been reprojected to: {1} and saved in {2}".format(projCount, spatialRef, OutFolder))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:32:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-getcount-help/m-p/516580#M40529</guid>
      <dc:creator>MarkWisniewski</dc:creator>
      <dc:date>2021-12-11T22:32:56Z</dc:date>
    </item>
    <item>
      <title>Re: Python - GetCount help</title>
      <link>https://community.esri.com/t5/python-questions/python-getcount-help/m-p/516581#M40530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For me this does the job:&lt;/P&gt;&lt;P&gt;Count_Lines = arcpy.GetCount_management(Meka)&amp;nbsp; &lt;/P&gt;&lt;P&gt;print Count_Lines ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 11:03:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-getcount-help/m-p/516581#M40530</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2015-04-16T11:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Python - GetCount help</title>
      <link>https://community.esri.com/t5/python-questions/python-getcount-help/m-p/516582#M40531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Ernst,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't believe you can use 'format' for the arcpy.AddMessage function.&amp;nbsp; Try the following instead:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14291837432257183 jive_text_macro" data-renderedposition="92_8_912_16" jivemacro_uid="_14291837432257183"&gt;&lt;P&gt;arcpy.AddMessage(str(projCount) + " datasets have been reprojected to: " + spatialRef + " and saved in " + OutFolder) &lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Apr 2015 11:29:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-getcount-help/m-p/516582#M40531</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2015-04-16T11:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Python - GetCount help</title>
      <link>https://community.esri.com/t5/python-questions/python-getcount-help/m-p/516583#M40532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Although you marked you question as solved already, let me add some additional information. You &lt;SPAN style="text-decoration: underline;"&gt;can&lt;/SPAN&gt; use a format statement inside the arcpy.AddMessage statement. I do it all the time and there is really no reason why you shouldn't. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I do see some strange indenting in you code, which may be the reason for a possible error. Was there an error occurring? Look at the slightly changed code below (I commented the project and copy statements)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
template = arcpy.GetParameterAsText(0)
arcpy.env.workspace = arcpy.GetParameterAsText(1)
OutFolder = arcpy.GetParameterAsText(2)

# Get the spatial reference
spatialRef = arcpy.Describe(template).spatialReference.name

# create a list of featureclasses in the current workspace
fcList = arcpy.ListFeatureClasses()

#Loop through shapfiles in folder and reproject
for fc in fcList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; fcspatialRef = arcpy.Describe(fc).spatialReference.name
&amp;nbsp;&amp;nbsp;&amp;nbsp; if fcspatialRef != spatialRef:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Projecting: {0}".format(fc))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # arcpy.Project_management(fc, os.path.join(outFolder , fc), template)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; process = "reprojected to"
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Copying: {0}".format(fc))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; process = "copied using"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # arcpy.CopyFeatures_management(fc, os.path.join(outFolder,fc))

&amp;nbsp;&amp;nbsp;&amp;nbsp; projCount = int(arcpy.GetCount_management(fc).getOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get the count from GetCount's Result object
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("{0} features (not datasets) have been {3}: {1} and saved in {2}".format(projCount, spatialRef, OutFolder, process))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on the inputs selected, this produced the following output in the geoprocessing window.&lt;/P&gt;&lt;P&gt;In case the sr is different:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Executing: revisarmensajes D:\Xander\GeoNet\DistFireHouse\datatest\firehistory.shp D:\Xander\GeoNet\DistFireHouse\shp D:\Xander\GeoNet\DistFireHouse\test
Start Time: Thu Apr 16 06:50:31 2015
Running script revisarmensajes...
Projecting: firehistory_NAD_fips3002_feet.shp
636 features (not datasets) have been reprojected to: NAD_1983_UTM_Zone_13N and saved in D:\Xander\GeoNet\DistFireHouse\test
Projecting: housesaledata.shp
7204 features (not datasets) have been reprojected to: NAD_1983_UTM_Zone_13N and saved in D:\Xander\GeoNet\DistFireHouse\test
Completed script revisarmensajes...
Succeeded at Thu Apr 16 06:50:31 2015 (Elapsed Time: 0,08 seconds)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In case the sr is the same:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Executing: revisarmensajes D:\Xander\GeoNet\DistFireHouse\shp\firehistory_NAD_fips3002_feet.shp D:\Xander\GeoNet\DistFireHouse\shp D:\Xander\GeoNet\DistFireHouse\test
Start Time: Thu Apr 16 06:51:17 2015
Running script revisarmensajes...
Copying: firehistory_NAD_fips3002_feet.shp
636 features (not datasets) have been copied to: NAD_1983_StatePlane_New_Mexico_Central_FIPS_3002_Feet and saved in D:\Xander\GeoNet\DistFireHouse\test
Copying: housesaledata.shp
7204 features (not datasets) have been copied to: NAD_1983_StatePlane_New_Mexico_Central_FIPS_3002_Feet and saved in D:\Xander\GeoNet\DistFireHouse\test
Completed script revisarmensajes...
Succeeded at Thu Apr 16 06:51:17 2015 (Elapsed Time: 0,08 seconds)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:32:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-getcount-help/m-p/516583#M40532</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-11T22:32:58Z</dc:date>
    </item>
  </channel>
</rss>

