Newbie question

Jeff Shannon jeff at ccvcorp.com
Wed Jan 30 17:07:25 EST 2002


Ramkumar Kashyap wrote:

> I am running Python 2.2 on Win2k.  How do I read the contents/files
> contained in a directory and also date created and dump it into a
> textfile or csv file?
>
> I am able to open single files in a directiory. Basically looking to get
> a 'dir' dump.
>
> TIA,
>
> Ramkumar

os.listdir(some_directory) will return a list of all the files in that
directory.  I think that in order to get the created-date, you'll need the
os.stat() function.  This returns a tuple of values; you can read the
documentation to find out how to get the specific information you need.
(Most functions that interact directly with the filesystem are in the os
module, and are mostly platform-independent.  Becoming at least passingly
familiar with os is a very good thing.  :) )

Jeff Shannon
Technician/Programmer
Credit International





More information about the Python-list mailing list