python, search file between two dates -


i make script in python , search files recursive in linux , between 2 dates?

import os  dirname, dirnames, filenames in os.walk('.'):      subdirname in dirnames:         print(os.path.join(dirname, subdirname))      # print path filenames.     filename in filenames:         print(os.path.join(dirname, filename)) 

like this?

import os, datetime dt  # define epoch time t0 = dt.datetime.utcfromtimestamp(0)  # define time ranges d1 = (dt.datetime(2015,1,1)  - t0).total_seconds() d2 = (dt.datetime(2015,1,31) - t0).total_seconds()  (dirpath, dirnames, filenames) in os.walk(path):     filename in filenames:         f = '/'.join([dirpath,filename])         ctime = os.stat(f)[-1]         if ctime>=d1 , ctime <=d2:              print f 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -