Python Forum
Need to identify only files created today.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need to identify only files created today.
#3
A Generator-Example:

import datetime
from pathlib import Path


def find_files_today(path):
    today = datetime.date.today()
    for file in Path().rglob("*"):
        try:
            is_file = file.is_file() # <- possible PermissionError
        except PermissionError:
            continue
        if not is_file:
            continue
        mdate = datetime.date.fromtimestamp(file.stat().st_mtime)
        if is_file and today == mdate:
            yield file
        
tester_V likes this post
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Messages In This Thread
RE: Need to identify only files created today. - by DeaD_EyE - Feb-17-2021, 09:52 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  identify not white pixels in bmp flash77 17 2,772 Nov-10-2023, 09:21 PM
Last Post: flash77
  i tried to install python for the first time today and pretty certain im being remote brianlj 2 612 Oct-03-2023, 11:15 AM
Last Post: snippsat
  guys please help me , pycharm is not able to identify my xlsx file CrazyGreenYT7 1 2,059 Jun-13-2021, 02:22 PM
Last Post: Larz60+
  code to read files in folders and transfer the file name, type, date created to excel Divya577 0 1,907 Dec-06-2020, 04:14 PM
Last Post: Divya577
  Make list of dates between today back to n days Mekala 3 2,445 Oct-03-2020, 01:01 PM
Last Post: ibreeden
  Store Previous date to calculate delta from today Captain_Wolf 7 3,407 May-08-2020, 06:08 PM
Last Post: SheeppOSU
  Need to identify sheet color in excel workbook chewy1418 2 2,592 Feb-14-2020, 03:26 PM
Last Post: chewy1418
  Find all “*.wav” files that created yesterday on linux host with python. pydeev 6 4,902 Jan-07-2020, 06:43 AM
Last Post: pydeev
  Need help to identify Mersenne Primes, I do need a search pattern. Pleiades 0 1,984 Dec-03-2019, 11:05 PM
Last Post: Pleiades
  Syntax Error : I can't identify what's wrong! caarsonr 11 6,440 Jun-10-2019, 11:18 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

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