Jul-21-2023, 11:57 PM
Greetings!
With a lot of help from this forum, I finally made a script for downloading (yesterday in Kuala_Lumpur) my today's files.
Still, my script downloads files with the wrong date. It looks OK but it does not really work as intended
.
I'm comparing the dates of the files and if matched - download...
Here is a snipped for downloading files:
Thank you!
With a lot of help from this forum, I finally made a script for downloading (yesterday in Kuala_Lumpur) my today's files.
Still, my script downloads files with the wrong date. It looks OK but it does not really work as intended

I'm comparing the dates of the files and if matched - download...
Here is a snipped for downloading files:
from datetime import datetime, date, time, timedelta from zoneinfo import ZoneInfo from pathlib import Path import shutil dt_to_find = dt.datetime.now().date() print(f" ========================= Target Day {dt_to_find} ========================= ") from_timezone = ZoneInfo('US/Pacific') to_timezone = ZoneInfo('Asia/Kuala_Lumpur') itmes = '\\\\somehost\\c$\\directory\\' # <--- Some Host in Asia/Kuala_Lumpur ndir_p = 'D:\\somedir\\' # <--------------- Directory for files from Kuala_Lumpur for echf in Path(items).iterdir(): if echf.is_file() : # Converting Time stamp to Date(Kuala_Lumpur) ef_time = echf.stat().st_mtime # <-------- Getting timeStamp dt3 = datetime.fromtimestamp(ef_time, to_timezone) dt33 = dt3.date() # <--------------------- Getting Date to match # Comparing two dates, Target date with the date from the Timestamp if dt33 == dt_to_find : try : print(f" {dt33} <-Time_ST.. {echf} .. Copying file") shutil.copy2(echf,ndir_p) except OSError as st : print(f" -- {st}")Any help is appreciated.
Thank you!