I am trying to rename shapefile with date (.format)
Question:
Hello I am getting error for this code I couldn’t find the problem
Error:
File "C:Scheduleopen_restaurants.py", line 74
txtFileNameNoExt = "{}_{}".format(os.path.splitext(txtFileNameWithExt)[0], datetime.datetime.now(%y_%m_%d))
^
SyntaxError: invalid syntax
#rename shapefile
txtFileNameWithExt = "Open_Restaurants.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))
Answers:
Hello I am getting error for this code I couldn’t find the problem
Error:
File "C:Scheduleopen_restaurants.py", line 74
txtFileNameNoExt = "{}_{}".format(os.path.splitext(txtFileNameWithExt)[0], datetime.datetime.now(%y_%m_%d))
^
SyntaxError: invalid syntax
#rename shapefile
txtFileNameWithExt = "Open_Restaurants.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))