Scanning folders

Darrell darrell at dorb.com
Tue Feb 29 22:06:22 EST 2000


If your talking about NT then give this a try.
http://www.dorb.com/darrell/win32WorkSvr/makeThumbsDG.py

def main():
    """
    Use events to avoid polling.
    A sleep is used to give most files a chance to finish
    being writen. Sort of a hack and might not be needed.
    The notification event LAST_WRITE seems to trigger
    at the start and end of writing. So a single file
    will trigger this twice.
    """
    hnd=win32file.FindFirstChangeNotification\
        (os.path.abspath('.')+os.sep+'incoming'\
        ,0, winnt.FILE_NOTIFY_CHANGE_LAST_WRITE )

    while 1:
        int = win32event.WaitForSingleObject( hnd, -1)
            # Try to give the file time to finish writing
        time.sleep(2)
        print 'run'
        try:
            passed, failed, skipped = makeThumbNails()
        except:
            if '-d' in sys.argv:
                traceback.print_exc()
            raise ThumbNailException
        win32file.FindNextChangeNotification(hnd)



----- Original Message ----- 
From: "Pieter Claerhout" <PClaerhout at CREO.BE>
To: <python-list at python.org>
Sent: Monday, February 28, 2000 3:35 AM
Subject: Scanning folders


> Hello,
> 
> what is the best and fastest way to scan a whole list of folders
> to see if something is added or not. Please note that this should
> also work for more than 1000 folders (and it shouldn't slow down
> the system too much).
> 
> Kind regards,
> 
> 
> Pieter
> 
> -- 
> http://www.python.org/mailman/listinfo/python-list
> 





More information about the Python-list mailing list