problem with running os.path.walk()

Discussion in 'Python' started by MalC0de, Oct 13, 2009.

  1. MalC0de

    MalC0de Guest

    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 .
    MalC0de, Oct 13, 2009
    #1
    1. Advertising

  2. En Tue, 13 Oct 2009 16:32:07 -0300, MalC0de <>
    escribió:

    > 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+

    --
    Gabriel Genellina
    Gabriel Genellina, Oct 13, 2009
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. leo
    Replies:
    1
    Views:
    526
    R.Marquez
    Apr 8, 2004
  2. Florian Lindner

    os.walk: Get entire path

    Florian Lindner, Aug 29, 2004, in forum: Python
    Replies:
    4
    Views:
    441
    Miki Tebeka
    Aug 30, 2004
  3. xtian

    Re: os.walk: Get entire path

    xtian, Aug 29, 2004, in forum: Python
    Replies:
    0
    Views:
    392
    xtian
    Aug 29, 2004
  4. Marcus Alves Grando
    Replies:
    7
    Views:
    457
    Marcus Alves Grando
    Nov 14, 2007
  5. dude
    Replies:
    5
    Views:
    1,690
    Jussi Piitulainen
    Mar 17, 2011
Loading...

Share This Page