[Tutor] counting new/changed files
Danny Yoo
dyoo@hkn.eecs.berkeley.edu
Mon, 18 Feb 2002 19:08:10 -0800 (PST)
On Mon, 18 Feb 2002, Tracy Bost wrote:
> Hi. I've finally getting to put python to some real world use here ! : )
> I'm a little stumped on counting the number of new/changed files in a
> directory since the last time it checked. I've thought about just
> writing the "check" time to a dictionary to a file, then each time it
> needs to check for the number of files that are new/changed, it can
> use that data as the reference point. Can someone be so kind as to
> point me the direction I need to go for counting these files ?
Hi Tracy,
There's a 'glob' function that helps us grab at all the filenames in a
directory; it lives in the 'glob' module:
http://www.python.org/doc/lib/module-glob.html
There's also a function called os.path.getmtime() function that tells us
when a particular file's been last modified:
http://www.python.org/doc/lib/module-os.path.html
If you'd like examples on how to use these functions, please feel free to
ask on Tutor, and we'll cook something up. Good luck!