Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

i need to remove the files from a folder every 4 hours. Otherwise storage folder will be filled with files and production server will be hang.

share|improve this question
please reword your question, it makes no sense and has many typos – mrTomahawk Jun 19 '09 at 13:49

You could create a batch file to delete the files in the subfolder, then create a scheduled task to run the batch file every 4 hours.

Since the windows scheduler doesn't allow for hourly tasks you would have to go into the advanced options and create multiple daily tasks that are offset by 4 hours from each other.

share|improve this answer
Third party products might provide more flexibility, but this will get the job done. – Philip Kelley Jul 24 '09 at 14:41

There is a vbs script (google for that we use to delete files that are older than a certain number of days from our fileserver. Not sure if it can be configured to work in 4 hours, but it would be a good place to start.

share|improve this answer

To delete all files from a storage folder, say C:\Temp, every four hours, I would use the following biterscript.

# Script delete.txt
while (true)
    # Collect a list of all files.
    var str list ; lf -n "*" "C:\Temp" ($ftype=="f") > $list

    # Delete all files
    while ($list <> "")
        var str file ; lex "1" $list > $file
        system delete ("\""+$file+"\"")

    # Sleep 4 hours.
    sleep (60*60*4)

Biterscripting can be downloaded from . The last time I checked, it was free.

I am enclosing the $file in the delete command in double quotes in case the file or path may contain spaces or other special characters.


share|improve this answer

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.