1. Hi Mario,

    Awesome little script you’ve wrote. I’ve just used it to clear up a whole bunch of logfiles and it does the job a treat!

    Interesting to learn about the forfiles command too, I think I need to refresh my knowledge of the Windows CommandLine!

    All the best,


  2. Elros Elrond


    Thanks a bunch for the script.
    Too bad it doesn’t run on my WIn XP :(
    It runs perfectly on my Win 2K3 though :)


  3. Hi Elros,

    Thanks for contacting me. I’m glad the script is working for you. Yes, that’s right. The script is for Windows 2003 Server computers only. The reason is the forfiles command.

  4. Elros Elrond

    Hi Mario,

    Turns out if you just copy forfiles.exe and choice.exe from a working Windows 2003 machine, your script works for XP as well. I just tried it yesterday :D

    An alternative for XP to achieve the same feat might be found at http://home.mnet-online.de/horst.muc/horst.htm though (see DELAGE).


  5. Hi Elros,

    That’s good to know. I didn’t try copying those files to my Windows machine. If I had tried that, I would have saved myself a lot of anxiety when I was testing my batch program on my employer’s Windows Server 2003 computer(s). :-)

  6. Eric Pfleckl

    Great script. It worked like a champ. Thanks!

  7. Senthil

    Hi Mario,
    This script helped me a lot.
    Thank you very much.


  8. Will

    Hi Mario

    There are lots of folders under the windows\system32\logfiles directory. (some are 2GB) Can i backup these folders adn leave a week of log files or can i only do this in the main directory.



  9. Ebbsa

    Hi Mario,

    Thanks for the script; it works great. Is there a way to delete a file on a remote server using a userid and password (possibly network userid and password)?



  10. Hi Ebbsa,

    You have to run the script locally on the server. If you don’t have physical access to the server, you can connect remotely to it via Remote Desktop and then run the script on it by first downloading it to the server. That’s the way I would do it.


  11. Katie

    Thanks for sharing your work and others a great deal of time! Works like a champ!

  12. Daniel

    First i would like to thank you for your grate post, do you know how to automatic answer yes?



  13. I have tons of IIS log files in customer’s space, especially at old customers. And I am so curious if deleting IIS log files are safe. Then I found out that that DNP and AWStats use these logs for bandwith calculation but it’s always safe to delete or archive logs older than 7 or 14 or 31 days as per your convenience.

Leave a Reply

Your email address will not be published. Required fields are marked *