Python to see if a file falls into a date range

Posted by tod on Super User See other posts from Super User or by tod
Published on 2013-07-01T21:20:57Z Indexed on 2013/07/01 23:07 UTC
Read the original article Hit count: 209

Filed under:
|
|
|

I have a script that I want to have an if statement check if a file falls between several specified date periods as it searches directories. I have been able to get the time in %Y-%m-%d format for the file, but I can't seem to be able to specify a date range for python to go through. Any ideas/help?

Here's what I have so far

for name in files:
    f = os.path.join(root, name)
    dt = os.path.getmtime(f)
    nwdt = time.gmtime(dt)
    ndt = time.strftime('%Y-%m-%d', nwdt)

© Super User or respective owner

Related posts about python

Related posts about time