<?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 error for f&amp;quot;{os.path in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-error-for-f-quot-os-path/m-p/1271434#M67211</link>
    <description>&lt;P&gt;f decorators are Python 3.&amp;nbsp; You'll have to use .format() like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#rename shapefile
txtFileNameWithExt = "Ops.shp"
txtFileNameNoExt = "{}_{}".format(os.path.splitext(txtFileNameWithExt)[0], datetime.datetime.now(%Y_%m_%d))
arcpy.env.workspace = my_Path
arcpy.Rename_management(txtFileNameWithExt,"{}.shp".format(txtFileNameNoExt))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Mar 2023 17:01:14 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2023-03-24T17:01:14Z</dc:date>
    <item>
      <title>python error for f"{os.path</title>
      <link>https://community.esri.com/t5/python-questions/python-error-for-f-quot-os-path/m-p/1271431#M67210</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I am getting error to run this code with Python 2.7&lt;/P&gt;&lt;P&gt;Error invalid characters at this part&lt;BR /&gt;&lt;BR /&gt;f"{os.path.splitext(txtFileNameWithExt)[0]}_{datetime.datetime.now():%Y_%m_%d}"&lt;/P&gt;&lt;P&gt;how can I fix this it? I need to run it on 2.7 .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;#rename shapefile
txtFileNameWithExt = "Ops.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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 16:54:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-error-for-f-quot-os-path/m-p/1271431#M67210</guid>
      <dc:creator>anonymous55</dc:creator>
      <dc:date>2023-03-24T16:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: python error for f"{os.path</title>
      <link>https://community.esri.com/t5/python-questions/python-error-for-f-quot-os-path/m-p/1271434#M67211</link>
      <description>&lt;P&gt;f decorators are Python 3.&amp;nbsp; You'll have to use .format() like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#rename shapefile
txtFileNameWithExt = "Ops.shp"
txtFileNameNoExt = "{}_{}".format(os.path.splitext(txtFileNameWithExt)[0], datetime.datetime.now(%Y_%m_%d))
arcpy.env.workspace = my_Path
arcpy.Rename_management(txtFileNameWithExt,"{}.shp".format(txtFileNameNoExt))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 17:01:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-error-for-f-quot-os-path/m-p/1271434#M67211</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-03-24T17:01:14Z</dc:date>
    </item>
    <item>
      <title>Re: python error for f"{os.path</title>
      <link>https://community.esri.com/t5/python-questions/python-error-for-f-quot-os-path/m-p/1271479#M67212</link>
      <description>&lt;P&gt;Thanks for replay&lt;BR /&gt;&lt;BR /&gt;I am getting error using your code&lt;BR /&gt;&lt;BR /&gt;File "C:\Sch\osp.py", line 74&lt;BR /&gt;txtFileNameNoExt = "{}_{}".format(os.path.splitext(txtFileNameWithExt)[0], datetime.datetime.now(%y_%m_%d))&lt;BR /&gt;^&lt;BR /&gt;SyntaxError: invalid syntax&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2023 18:21:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-error-for-f-quot-os-path/m-p/1271479#M67212</guid>
      <dc:creator>anonymous55</dc:creator>
      <dc:date>2023-03-24T18:21:06Z</dc:date>
    </item>
    <item>
      <title>Re: python error for f"{os.path</title>
      <link>https://community.esri.com/t5/python-questions/python-error-for-f-quot-os-path/m-p/1271528#M67215</link>
      <description>&lt;P&gt;yep,&amp;nbsp; need to format the date there...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#rename shapefile
txtFileNameWithExt = "Ops.shp"
dte = datetime.datetime.now()
txtFileNameNoExt = "{}_{}".format(os.path.splitext(txtFileNameWithExt)[0], dte.strftime('%Y_%m_%d'))
arcpy.env.workspace = my_Path
arcpy.Rename_management(txtFileNameWithExt,"{}.shp".format(txtFileNameNoExt))&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 24 Mar 2023 20:00:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-error-for-f-quot-os-path/m-p/1271528#M67215</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-03-24T20:00:30Z</dc:date>
    </item>
  </channel>
</rss>

