problem with running os.path.walk()

M

MalC0de

heya there,
where's the problem with the following code ? I couldn't see any
result while running as a script :


#!/usr/bin/python
import time
import os
def walker2(arg,dirname,filenames):
cutoff = time.time() - (arg * 24 * 60 * 60)
for filename in filenames :
stats = os.stat(dirname + os.sep + filename)
modified = stats[8]
if modified >= cutoff :
print dirname + os.sep + filename

os.path.walk('C:\\windows\\system',walker2,30)



if I have problem with it then let me know and if is possible please
fix it up .
thnx .
 
G

Gabriel Genellina

where's the problem with the following code ? I couldn't see any
result while running as a script :


#!/usr/bin/python
import time
import os
def walker2(arg,dirname,filenames):
cutoff = time.time() - (arg * 24 * 60 * 60)
for filename in filenames :
stats = os.stat(dirname + os.sep + filename)
modified = stats[8]
if modified >= cutoff :
print dirname + os.sep + filename

os.path.walk('C:\\windows\\system',walker2,30)

if I have problem with it then let me know and if is possible please
fix it up .

Because all files in your c:\windows\system directory are older than one
month?
os.walk is simpler to use; stats.st_mtime is less "magical" than stats[8];
and I'd use os.path.join(dirname, filename) instead of +os.sep+
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,054
Latest member
LucyCarper

Latest Threads

Top