Skip to content Skip to sidebar Skip to footer

In Python How Do I Search For Files Created In The Past 24 Hours?

I am new to python and I want to find all files in a directory that have been created within the past 24 hours. How do I filter the files that were created in 24 hour window. This

Solution 1:

Get the stat of the file then check if its less then 24 hours... You will need to do loop/recreation...

import os
import time
st = os.stat("test.py")
ctime = st.st_ctime
print time.time() - ctime/3600 // hours
    if mtime<24:
       print mtime

Post a Comment for "In Python How Do I Search For Files Created In The Past 24 Hours?"