2

So I am able to extract all the file names into a text file, but there are millions of results. How do I limit it to only look at files created in the last 24 hours/1 day ???

This is my code so far.

with open("output.txt", "w") as a:
    for path, subdirs, files in os.walk(r'\\somefolder'):
      for filename in files:
         f = os.path.join(filename)
         a.write(str(f) + os.linesep)

thank you for your help

jpp
  • 159,742
  • 34
  • 281
  • 339
grahamie
  • 301
  • 2
  • 6
  • 15
  • 2
    have you tried [getting the last modified time](https://stackoverflow.com/a/39501288/9209546), then [taking the difference between two times](https://stackoverflow.com/a/25265500/9209546) and performing an `if` condition based on this value? – jpp Feb 07 '18 at 23:26
  • 1
    Possible duplicate of [Python, Deleting all files in a folder older than X days](https://stackoverflow.com/questions/12485666/python-deleting-all-files-in-a-folder-older-than-x-days) – KJoke Feb 07 '18 at 23:29

0 Answers0