<?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: How add current date to output when I convert feature class to shapefile? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143705#M63744</link>
    <description>&lt;P&gt;I wrote mine in Spyder... I don't know much about PyScripter, but maybe it needs a reference to the 'os' or 'datetime' modules&lt;/P&gt;</description>
    <pubDate>Mon, 14 Feb 2022 17:12:58 GMT</pubDate>
    <dc:creator>KimberlyGarbade</dc:creator>
    <dc:date>2022-02-14T17:12:58Z</dc:date>
    <item>
      <title>How add current date to output when I convert feature class to shapefile?</title>
      <link>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143341#M63732</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;BR /&gt;I am trying to rename shapefile to current date like this dd_02112022.zip&lt;BR /&gt;I am created zip file but I can't find out how to rename shapefile or feature class before zipping all together.&lt;/P&gt;&lt;P&gt;any python code or arcpy to rename and add current date.&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Fri, 11 Feb 2022 21:44:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143341#M63732</guid>
      <dc:creator>anonymous55</dc:creator>
      <dc:date>2022-02-11T21:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: How add current date to output when I convert feature class to shapefile?</title>
      <link>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143357#M63733</link>
      <description>&lt;P&gt;many ways to generate the date string, here is one.&amp;nbsp; I assume you have the rest in hand&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from datetime import datetime as dt

n = dt.now()

"-".join([f"{i}" for i in [n.year, n.month, n.day]])
'2022-2-11'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Feb 2022 23:05:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143357#M63733</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-02-11T23:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: How add current date to output when I convert feature class to shapefile?</title>
      <link>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143480#M63735</link>
      <description>&lt;P&gt;This worked for me using the rename_management function and a shapefile.&amp;nbsp; It took a shapefile name Kim.shp and renamed it to append todays date... the code to create the zip file works to, but it creates a zip file that starts at the base of the path... if that makes sense.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KimGarbade_3-1644775008572.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33806i5E5659AD4576C699/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KimGarbade_3-1644775008572.png" alt="KimGarbade_3-1644775008572.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KimGarbade_4-1644775081222.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33807i66162B6C31A127E8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KimGarbade_4-1644775081222.png" alt="KimGarbade_4-1644775081222.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Feb 2022 17:59:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143480#M63735</guid>
      <dc:creator>KimberlyGarbade</dc:creator>
      <dc:date>2022-02-13T17:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: How add current date to output when I convert feature class to shapefile?</title>
      <link>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143693#M63742</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/119500"&gt;@KimberlyGarbade&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't way but I run your code on jupyter notebook on Arcpro and works fine when I am trying to run on PyScripter I am getting error&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ARM_1-1644857821387.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33856iF54406271BB9B034/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ARM_1-1644857821387.png" alt="ARM_1-1644857821387.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#rename shapefile
txtFileNameWithExt = "op.shp"
txtFileNameNoExt = f"{os.path.splitext(txtFileNameWithExt)[0]}_{datetime.datetime.now():%Y_%m_%d}"
arcpy.env.workspace = my_Path
arcpy.Rename_management(txtFileNameWithExt,f"{txtFileNameNoExt}.shp")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 16:58:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143693#M63742</guid>
      <dc:creator>anonymous55</dc:creator>
      <dc:date>2022-02-14T16:58:07Z</dc:date>
    </item>
    <item>
      <title>Re: How add current date to output when I convert feature class to shapefile?</title>
      <link>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143700#M63743</link>
      <description>&lt;P&gt;you are missing a matching&amp;nbsp; }&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 17:07:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143700#M63743</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-02-14T17:07:42Z</dc:date>
    </item>
    <item>
      <title>Re: How add current date to output when I convert feature class to shapefile?</title>
      <link>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143705#M63744</link>
      <description>&lt;P&gt;I wrote mine in Spyder... I don't know much about PyScripter, but maybe it needs a reference to the 'os' or 'datetime' modules&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 17:12:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143705#M63744</guid>
      <dc:creator>KimberlyGarbade</dc:creator>
      <dc:date>2022-02-14T17:12:58Z</dc:date>
    </item>
    <item>
      <title>Re: How add current date to output when I convert feature class to shapefile?</title>
      <link>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143708#M63745</link>
      <description>&lt;P&gt;I checked and I don't miss anything&lt;BR /&gt;seems &lt;STRONG&gt;"f"&amp;nbsp;&lt;/STRONG&gt;doesn't work here&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ARM_0-1644858724264.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/33860iD5EFFF9C083CDFAA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ARM_0-1644858724264.png" alt="ARM_0-1644858724264.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;txtFileNameNoExt = f"{os.path.splitext(txtFileNameWithExt)[0]}_{datetime.datetime.now():%Y_%m_%d}"&lt;BR /&gt;^&lt;BR /&gt;SyntaxError: invalid syntax&lt;/P&gt;&lt;P&gt;also here&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = my_Path&lt;BR /&gt;arcpy.Rename_management(txtFileNameWithExt,f"{txtFileNameNoExt}.shp")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 17:13:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143708#M63745</guid>
      <dc:creator>anonymous55</dc:creator>
      <dc:date>2022-02-14T17:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: How add current date to output when I convert feature class to shapefile?</title>
      <link>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143716#M63747</link>
      <description>&lt;P&gt;"f" substitution only works in Python 3.6 and above.... might have to use an older substitution method.&amp;nbsp; You could try % formatting... its an older way to do string substitution in Python.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 17:18:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-add-current-date-to-output-when-i-convert/m-p/1143716#M63747</guid>
      <dc:creator>KimberlyGarbade</dc:creator>
      <dc:date>2022-02-14T17:18:28Z</dc:date>
    </item>
  </channel>
</rss>

