Batch file to delete files older than x days from folders in Windows

I’ve been working for a client over recent months and part of my resposibility has been to look after a number of servers used for performance testing. Occasionally drives fill up on the server farm causing outages and obvious interruptions to testing.

It would be a near full-time job to manage all these servers, so to reduce the chance of temporary files from filling up drives and causing problems, I looked into creating a scheduled task to delete old temporary files. Since my server estate is varied, I didnt want to use PowerShell so I opted for an old “DOS” command, FORFILES.

This seems to have done the trick for me:
forfiles /s /m *.* /d -7 /c "cmd /c del @path"

(This command deletes all files that are more than 7 days old from the folder in which it runs.)

Update – To remove folders as well:
forfiles /S /D -7 /C "cmd /c IF @isdir == TRUE RMDIR @path /S /Q"

(This command deletes all folders that are more than 7 days old from the folder in which it runs. – Run it after deleting the files with the command above.)

 

Introduction to performance testing at the NWTG

I really enjoy the NWTG events in Manchester which arintro_nwtge great for the testing community in this area.  I’ve noticed that performance testing is “under represented” at these events (which frequently
have a functional-testing bias).  With this in mind, I tried to give an introduction to performance testing.

For those unable to attend, the slides are available on SlideShare.

….and a video of the presentation is available on YouTube.
(My son thinks that the number of “ums” and “erms” is hilarious. I’m hoping to reduce the number of these “linguistic fillers” for my next presentation)

The final slide includes links to the Trust IV LoadRunner download page as well as blogs that I have found helpful during my time as a tester.

If anybody wants to learn more, don’t hesitate to contact @RichardBishop or @TrustIV via Twitter.

Adding JavaScript functions to LoadRunner

After reading Boris Kozorovitzky’s blog article, “How to use JavaScript in your HP LoadRunner scripts”, I’ve been inspired to experiment with LoadRunner 12.

Historically, most LoadRunner functions have been written in C but many performance testers (me included) aren’t particularly fond of C and prefer to use more up to date languages. I was already aware that there are some great JavaScript libraries out there which can extend the functionality of LoadRunner, but I hadn’t tried them until now.

Boris’ article describes how to integrate JavaScript code into your C-based scripts. Following his guidance I developed a script which uses the DateJS function for date calculations. I’m impressed with the flexibility of DateJS and the extra capabilities that it offers over the standard LoadRunner date/time functions.

To incorporate the DateJS functionality into my script I did the following:

  • Turned on the “Enable running JavaScript code” function.
    Run-Time Settings > Internet Protocol > Preferences > Set advanced options > Options
  • Added my date.js code into the script using Solution Explorer.
    Right-click “Extra Files”node in Solution Explorer
    then choosing the option to “Add files to script”
  • Adding JS functions to the script is then achieved by using the LoadRunner web_js_run function.

    e.g.

    JavaScript example in LoadRunner
    JavaScript example in LoadRunner

I added my sample script to my GitHub repository so that other people can see just how easy this is and potentially benefit from the new date/time functions in this sample LoadRunner script.

You can download the script here: https://github.com/richardbishop/LoadRunnerSamples/tree/master/DateJS