How to rename and relocate the most recently downloaded file via python?

Viewed 74

I'm just wondering how I can write a code that locates the most recently downloaded file - without me knowing the name of said file - and renames and relocates it to a specified directory via Python

list_of_files = glob.glob("C:\\Users\\shashem\\Downloads\\*")
latest_file = max(list_of_files, key=os.path.getctime)
mypath = "C:\\Users\\shashem\\Desktop"
old_name = max(list_of_files, key=os.path.getctime)
new_name = input("Testnew")
new_path = "C:\\Users\\shashem\\Desktop"
os.rename()'

This is where I am, obviously not finished, but I'm a bit lost and would appreciate any proposed solutions.

0 Answers
Related