Searching for and sorting files by date and compiling stats in Windows

James Kew james.kew at
Thu Sep 26 18:00:46 EDT 2002

"A. Dimsdale and A. Moser" <fetus at AUTO> wrote in message
news:MOKk9.66578$U7.23791943 at
> How can I do the following in Python:
> * Search through networked Windows drives for the string "~w*.tmp" (*
> wildcard of course) in the filename

os.path.walk and match a regular expression against each file in names on
each callback.

> * Calculate how much disk space is taken up by Word temp files by date
> (i.e., files with "~w*.tmp" as their filenames with date modified in 2001
> drive G: on SDspam01 use 75 MB total, files with "~w*.tmp" as their
filenames with date modified in August 2002 on drive H: on DCspam04 use 60
MB total, etc.)

os.stat on each matching file.

> * Optimally, automagickally put this data into an MS Excel spreadsheet

win32com.client, but that's the easy part; the difficult part is working out
how to use Excel's automation interfaces to do what you want to do. Dumping
the data into a CSV file might be a half-reasonable substitute.


More information about the Python-list mailing list