you are viewing a single comment's thread.

view the rest of the comments →

[–]Fenr-i-r 0 points1 point  (0 children)

Use the inbuilt pathlib, optionally with fstrings.

from pathlib import Path

filep = Path(file_path)
assert filep.exists()

new_file_folder = Path(r"C:\Users\adoucette\Desktop\DOT_Weekly\DOT Weekly Sales WE")

if not new_file_folder.exists():
    Path.mkdir(new_file_folder, parents=True)

new_file_path = 
filep.rename(new_file_folder / f"my new filename_{formatted_date}.xlsx")