Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a program that constantly checks a certain file size on hard drive, like every 5 minutes or something?

If the file size stops increasing, I would run some action X (X set by the user – like maybe launch an application or play a sound).

OS - Windows 7 Home

The following code is not working. It is not picking up the file size properly. When I right click on the file and check its size, it's constantly updated. However, AutoIt script seems not to be grabbing the correct size every 2 minutes. When I increase the time interval to 5 minutes, only then it picks up the updated size SOMETIMES.

Global $logging = True
$file = $CmdLine[1] & "\" & $CmdLine[2]
_log("Filename: " & $file)
$size = 0 ;set initial size to 0
Sleep(60000) ;sleep 1 minute
If FileExists($file) Then
    While 1 ;loop indefinitely
        $filesize = FileGetSize($file) ;get current size of file
        _log("File Size: " & $filesize)
        If $filesize = $size Then ;compare new size with old size
            _log("Download Halted: " & $filesize) ;notify that file is complete
            Run("AStart.bat", $CmdLine[1])
            ExitLoop ;exit
        $size = $filesize ;save current file size
        Sleep(120000) ;sleep 2 minutes
    MsgBox(0, "File Not Found", "File Not Found! - " & $file)

Func _log($message)     
    If $logging Then ; global variable where you can globally switch OFF/ON logging      
        FileWriteLine(@ScriptDir & "\file.log", @YEAR & "-" & @MON & "-" & @MDAY & "-" & @HOUR & ":" & @MIN & " --> " & $message)     
share|improve this question
What OS? The method would be vastly difficult depending on the system. – Nov 1 '11 at 23:33
You would be better off describing the problem you are having - there may be better ways to solve it than monitoring the output file. – Paul Nov 1 '11 at 23:34
What OS do you use? With UNIX-like systems you could run a cron-job (shell script) every 5 minutes that does what you want. – ott-- Nov 1 '11 at 23:35
I don't know of any, but this is something that could be easily handled with a small script. For example, if you are using windows, AutoIt has some good functions for this sort of thing (FileOpenDialog, FileGetSize, SoundPlay, ShellExecute). Use them with a simple loop and you have exactly what you want. – MaQleod Nov 1 '11 at 23:36
@Paul I did ask here, but nobody responded, so I thought my question was inappropriate… – TPR Nov 1 '11 at 23:41

Here is a simple AutoIt script that will cycle every 3 minutes and check a specified file for change in file size. If there is no change in that 3 minutes, it will pop up a message box. I commented it so you can see what each line does. It should be easy to modify for your needs along with AutoIt's well documented help file and active help forum.

$file = FileOpenDialog("Select a File", @MyDocumentsDir, "All (*.*)") ;select a file
$size = 0 ;set initial size to 0

While 1 ;loop indefinitely
    $filesize = FileGetSize($file) ;get current size of file
    If $filesize = $size Then ;compare new size with old size
        MsgBox(64, "Download Complete", "File size has not changed in 3 minutes, download complete") ;notify that file is complete
        ExitLoop ;exit
    $size = $filesize ;save current file size
    Sleep(180000) ;sleep 3 minutes

Other functions you may be interested in: ShellExecute() Run() SoundPlay() TimerInit() TimerDiff() FileExists()

share|improve this answer
any idea why FileGetSize is not working? See my post. Is it a known issue? – TPR Nov 5 '11 at 11:00

Not that I know of, but, I just created something that can do this for you!


enter image description here

You start it up, choose the file to watch, select the timer, select the condition to watch for and finally the file to launch upon the condition being met.

Please note, that this is something I just wrote in a few minutes, I have tested it, but, no guarantees...

Download Link

share|improve this answer
I know you said play a sound or other action - I have never mucked around with Audio and I would probably muck it up... You can easily set a batch file or similar using this application, so, you can always play a sound through that and a third party app or similar. – William Hilsum Nov 2 '11 at 0:42
It didnt work for me! I do appreciate the effort. What OS did you test it on? – TPR Nov 5 '11 at 11:01
@progtick Windows 7 - what is the issue you are having? – William Hilsum Nov 5 '11 at 11:02
It doesn't launch the file. I tried both options "Changes" and "Does Not Change" – TPR Nov 5 '11 at 11:33
@progtick ... I don't suppose you mind testing it again? I just use the Shell command it appears to work here, so, I am little worried if it doesn't work elsewhere! Can you put the timer to 1, then create a text file on your desktop with garbage text in it, choose that file with c:\windows\system32\calc.exe as the launch file... then click start (once)... And try changing the text file? ... If you can't get that to work, I will see if there is anything I can do quick, but, I can't see the error here :( – William Hilsum Nov 5 '11 at 11:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.