File cleanup/rotation

General purpose file rotation and deletion. Handles multiple cleanup jobs, logs and alerts on run results and errors, and does "whatif" modeling to see what effect a job configuration will have on a directory.

5 Star
Add to favorites
E-mail Twitter Digg Facebook
  • Recurse through sub directories
    11 Posts | Last post June 28, 2011
    • How can we make this recurse through sub drirectories and delete empty folder.
      By the way great job.
    • I'll have to investigate that.  Can I ask what your application is?  That sounds kind of atypical for a file rotation/cleanup.
    • Hi mjolinor,
      Same question as Brendon. The app are users who save files to temporary folder, and never delete it. So I need to delete anything not touched for 2 weeks.
      And thanks for great script.
      This is an absolute godsend, great job. I am a complete newbie to scripting, let alone powershell yet I was asked to do exactly this. I cannot thank you enough. The ability to create configurable jobs and then run as a batch is out of this world. God bless you!
    • Awesome script although I really wish it would delete all files in sub-directories. We have an ftp server and want to clean the user folders of old files.
    • FYI ... I had to make this change (near line 300) to get the script to work:
          sl $job.filespec
          foreach ($old_file in $old_files){Remove-Item $old_file}
      (I added the "sl $job.filespec" ... without it, it was throwing exceptions on each file it was trying to delete, showing a filepath of the directory where the "job-...xml" files were located, rather than the path of the files to be deleted)
    • Wow ... sorry about that prior comment ... when it saved, all of the formatting was removed 
      Please see the following two additional comments for the code change, which is near line 300.
      The first line is what I inserted, the second line was already existing ...
    • sl $job.filespec
    • foreach ($old_file in $old_files){Remove-Item $old_file}
    • I am totally new and extremely limited knowledge of scripts, when I found this script with it's functionality listed I thought of using this readymade and copied the same onto notepad & saved with .Vbs extn. But when I double click the same it gives me an error called "Expected Statement" on Line1 & Char1.
      Please help.
    • This is a Powershell script, not vbs.