Python Forum
Have to use Python 2.x to find "yesterday' files
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Have to use Python 2.x to find "yesterday' files
#1
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:
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!
Reply


Messages In This Thread
Have to use Python 2.x to find "yesterday' files - by tester_V - Sep-18-2021, 02:28 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Find duplicate files in multiple directories Pavel_47 9 3,108 Dec-27-2022, 04:47 PM
Last Post: deanhystad
  count every 28 files and find desire files RolanRoll 3 2,074 Dec-12-2021, 04:42 PM
Last Post: Axel_Erfurt
  find 'yesterdays files' tester_V 8 3,843 Jun-18-2021, 02:10 AM
Last Post: tester_V
  Find and replace in files with regex and Python Melcu54 0 1,850 Jun-03-2021, 09:33 AM
Last Post: Melcu54
  List of error codes to find (and count) in all files in a directory tester_V 8 3,687 Dec-11-2020, 07:07 PM
Last Post: tester_V
  helping PyInstaller To Find files Harshil 0 1,486 Aug-30-2020, 10:16 AM
Last Post: Harshil
  Find specific subdir, open files and find specific lines that are missing from a file tester_V 8 3,583 Aug-25-2020, 01:52 AM
Last Post: tester_V
  python 3 find difference between 2 files pd007 2 2,135 May-22-2020, 01:16 AM
Last Post: Larz60+
  Find all “*.wav” files that created yesterday on linux host with python. pydeev 6 4,784 Jan-07-2020, 06:43 AM
Last Post: pydeev
  finding yesterday and tomorrrow without using date.time module apexman 10 5,518 Feb-25-2019, 05:33 AM
Last Post: samsonite

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020