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.)

 

Twilight, fl.ux and Light Dims

It’s widely accepted that bright lights, especially blue-tinged lights from tablets, smartphones and PCs are contributing to sleep deprivation. Articles such as “Bright Screens Could Delay Bedtime” in Scientific American and “Screen reading before bed can ruin your sleep” on wired.co.uk all describe how screen reading late at night can disrupt sleep patterns and lead to poor health.

Twilight and fl.ux

I’m a bit of a screen junkie and I decided that I’d try to improve my own sleep patterns. I installed Twilight onto my Android phone and fl.ux onto my PC and laptop. These applications keep track of the local sunset times and add a red hue to the screen after sunset. I’m not 100% sure whether this has improved my sleep patterns yet, but it does serve as a useful prompt to switch my screen off when my eyelids start to droop! 😉

Light Dims

The other thing that annoys me at home is my alarm clock radio. It casts a bright green light across the bedroom and I can even see the brightness through closed eyelids. I’ve tried sticking Post-it notes over the display, but this isn’t ideal. To reduce the problem of night-time glare I ordered some “Light Dims” online. Despite coming from America, delivery was only $0.99 (£0.65) and the stickers arrived within a few days. I fitted a sticker over my alarm clock display and one on the TV LED in the bedroom. I’m pleased to say that they do exactly what the website says.

Light Dims

Night-time glare is much reduced, I’m looking forward to better sleep patterns 🙂

Outlook’s brighter for Trust IV

Those of you with long memories may remember my Trust IV blog article unveiling the webcam this time last year.

Since then our windows have got dirtier and the picture quality has degraded. The good news is that spring is in the air and our building’s having a spring clean. Our webcam caught the cleaner’s in the act. I hope you like the new, improved view from the webcam.