Jun-16-2021, 09:50 PM
Greetings!
I guess the question is not new, but I cannot find a clan small snippet.
I found one here, on this forum - it has a function and 25 lines of code, it is not small or clean.
Anyway, need to scan a directory and find (and copy) files created yesterday.
I got this so far:
Thank you.
I guess the question is not new, but I cannot find a clan small snippet.
I found one here, on this forum - it has a function and 25 lines of code, it is not small or clean.
Anyway, need to scan a directory and find (and copy) files created yesterday.
I got this so far:
import os import time import datetime today = datetime.date.today() td = today.ctime() print(f" Today --> {td}") dirtoscan = "c:\\0001\\" for fl in os.listdir(dirtoscan) : f_path = os.path.join(dirtoscan,fl) modified = os.path.getmtime(f_path) dateModif = time.ctime(modified) print(f"File Modif --> {dateModif}")I could split 'td' get a Second Element of spit
td = today.ctime()And Split 'datemodif' to get Second Element of split
dateModif = time.ctime(modified)and compare them, but it looks awful, ugly kind of code...
Thank you.