Kaseya Community

delete files script

  • hi guys,

    I want to create a script to clean up disk space for me, on one particualar server I get a lot of log files growing in a folder and I can delete them, I want the script to delete everything bar the latest one, how would I tell it to do that?

  • I built a simple script around a little app called DelOld.exe (I'm sure there are others which do the same thing), just pointed it at a directory and said "delete anything older than X days". This is great for dealing with those pesky W3SVC LogFiles directories on SBS machines which never get cleared out normally, for instance...


  • Delete files older than 7 days using this dos command.  You can use this with "Execute Shell Command" as System:

    forfiles /p "c:\path\to\logfile\directory" /s /m *.* /d -7 /d "cmd /c del @path"

    If you only want it to catch *.log files, change /m *.* to /m *.log

    want older than 7 days?  change -7 to -14