Reputation: 3503
What is a good way to find out the last updated time of a directory? Note that this includes update to any levels of the subfolders as well. I know I can use os.path.getmtime
or os.stat
but they seem to work only if the immediate contents of the folder are changed. Do I need to recursively check for all subfolders and get the max modified time or is there a better way to do this?
Upvotes: 3
Views: 767
Reputation: 3917
You can use os.walk
...
m = max(map(lambda x: os.path.getmtime(x[0]), os.walk("directory")))
Upvotes: 4