Q:

Detect if the contents of a folder have changed?

Conditions:

Windows 98 SE
WMI not available

I have code that looks like this, written using my steroidal wrapping of VBScript using MSScript.
do
    a = files.collectfiles( "c:\userver", "" )
    for i = 0 to ubound( a )
        f = a(i)
        if strings.endswith( f, ".usv" ) then
            d = files.readfilee( f )
            on error resume next
            executeglobal d
            nErr = err.number
            sErr = err.description
            on error goto 0
            if nErr <> 0 then
                trace "*** Error " & nErr & ", " & sErr
            end if
            files.deletefile f
        end if
    next
    system.sleep 10
    system.cooperate
loop

There's a lot of disk activity with that call to files.collectfiles. Is there some way of detecting a change in the contents of a folder without actually scanning the folder for files?

A:

Define "change in the contents of a folder".
If it means that a file was added, deleted, or renamed, then the modified timestamp of the folder is updated whenever such an event occurs.
If you're instead wanting to know when files are modified, then you'll need to read them.
That said, looking at what you're trying to do (scan a folder for new .usv files, and process them and delete them), then just keeping track of the timestamp on the folder and updating it right before you call collectfiles is best (note that the correct time to log is just BEFORE calling collectfiles, otherwise you run the risk of not waking up if a file gets added during the collectfiles call or immediately afterward).

