[Tutor] newbie questions (directory listing)

Denis spirou@carolo.com
Wed, 22 Nov 2000 01:56:40 +0100


Le Tue, Nov 21, 2000 at 03:59:39PM -0800, Larry Kuhn pianota:
> In theory, I should be able to assign a path to a variable,
> assign a date to another variable, create a loop that compares
> the file modification time to the date in the variable, write
> the name and path of a file that matches the date to a text
> file, increment the loop, and walk the directory tree to the
> bottom. I realize theory and practice are often different
> from each other.

Have a look at os.path.walk() and os.stat()

>>> import os
>>> print os.path.walk.__doc__
walk(top,func,args) calls func(arg, d, files) for each directory "d" 
in the tree  rooted at "top" (including "top" itself).  "files" is a list
of all the files and subdirs in directory "d".

>>> print os.stat.__doc__
stat(path) -> (mode,ino,dev,nlink,uid,gid,size,atime,mtime,ctime)
Perform a stat system call on the given path.
>>> 

Have fun
-- 
Denis FRERE
P3B    : Club Free-Pytho-Linuxien Caroloregien http://www.p3b.org
Aragne : Internet - Reseaux - Formations  http://www.aragne.com