I'm trying to rename a file using Python code that is in Downloads folder but I keep receiving below error. I cannot find the absolute path.
FileNotFoundError: [WinError 3] The system cannot find the path specified: '~/Downloads/Test.xlsx' -> 'Test_2023-01-25 14:04:51.552908.xlsx'
Here is the code:
import os
import datetime
dt = str(datetime.datetime.now())
newname = 'Test_'+dt+'.xlsx'
os.rename('~/Downloads/Test.xlsx', newname)
Appreciate all the help I can get. Thank you very much in advance.