Sep-18-2021, 02:28 AM
Greetings!
I'm trying to identify (and later copy) some files, the problem is the systems I must use have only Python 2.7 installed.
I managed to get the timestamp of the files I'm scanning and the 'yesterday' string to compare the files against.
I'm still failing to identify the "yesterday' files.
here is the code:
I'm trying to identify (and later copy) some files, the problem is the systems I must use have only Python 2.7 installed.
I managed to get the timestamp of the files I'm scanning and the 'yesterday' string to compare the files against.
I'm still failing to identify the "yesterday' files.
here is the code:
import os import datetime as dt import datetime prd_dr = 'c:\\02\\' for items in os.listdir(prd_dr) : items=items.strip() if 'Monitor.' in items : fls = os.path.join(prd_dr,items) print(' Path_file -> ',fls) tt = os.path.getmtime(fls) time_stamp=datetime.datetime.fromtimestamp(tt) print(fls,time_stamp) yesterday = dt.datetime.now().date() - dt.timedelta(days=1) print ('YEStERDAY',yesterday) if time_stamp == yesterday : print('---------',fls)Thank you!