1

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.

p.campbell
  • 4,407
  • 6
  • 41
  • 51
user9950
  • 199
  • 2
  • 5

3 Answers3

6

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.

Nate
  • 524
  • 3
  • 10
0

There is a vbs script (google for deleteoldfiles.zip) 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.

Brent
  • 22,857
  • 19
  • 70
  • 102
0

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)
do
    # Collect a list of all files.
    var str list ; lf -n "*" "C:\Temp" ($ftype=="f") > $list

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

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

Biterscripting can be downloaded from http://www.biterscripting.com . 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.

Patrick