Originally Posted by
nix4me
Im trying to get the script to get the dir listing, evaluate all of the folders in that dir and print only the dirs that are 1 week old or less, 1 per line.
i have showed you a snippet of how it can be done.
use os.path.getmtime (or ctime, or atime depending on your requirements).
eg
Code:
>>> import time,os
>>> today=time.time()
>>> filetime = os.path.getmtime("file")
1179703606
you get seconds. 1 week is roughly equivalent to 24 * 60 * 60 * 7 =
604800 seconds, so you subtract today's time with 604800 and that is the time
one week ago.Store it in a variable then in your script you can check whether filetime is less than one week and
print it.
Bookmarks