Delete files more than X Days old. On one of our servers we have a batch processing program. It is old and clunky, but it gets the job done. An irritating bug it has is that it leaves temp files around in the c: \windows\temp folder. One day we noticed the server was getting slow – finally realized that the temp folder had over 1. We don’t have the code for this program, so we can’t fix the bug. An easy fix would be to setup a scheduled task to trash that folder every night.

Oscar would like to have all those files every night, but the problem with this solution is it can cause problems with apps that actually are *using* those temp files. What we needed was a way to delete files that were over 1 day old. This was enough to make sure the temp file was no longer used by any of our processing apps. After searching around, I found a command line program that Microsoft included with some versions of windows.


SOLWAY S SD CARD TESTER Check and test the integrity of SD cards before you use them. Cheap SD cards purchased online are sometimes faulty. Make sure they work. In Pieces is an interactive environmental protection site where you can learn about your favorite animal, what’s killing them, and where you can donate to help.
It is called “forfiles”For. Files will process a command against files and folders that match your criteria. It allows you to set wildcards, pick only folders, or only files. The default folder is the current working directory/M Search Mask - Searches files according to a searchmask.
The default searchmask is '*' ./S Sub Directories Instructs forfiles to recurse into subdirectories. Command strings should be wrapped in double quotes.
The following variables can be used in the command string: @file - returns the name of the file.@fname - returns the file name without extension.@ext - returns only the extension of the file.@path - returns the full path of the file.@relpath - returns the relative path of the file.@isdir - returns . Internal CMD. exe commands should be preceded with . It has everything we need.
Lets start out with the path. We want it to look in c: \windows\tempforfiles - p . So there it is – a one line command that will delete files from our temp folder over 1 day old: forfiles - p . I highly suggest keeping a copy on your flash drive.
One more thing. Click Here to get your free tools.
Scheduled task won't run . I like to disable all non- MS Services and Startups before I do updates, or install software. I have been doing that through msconfig / Services, and CCleaner / Tools / Startup. Unfortunately, these two ways do not allow me to disable some things in Startup (Notepad++, Firefox URL to Y- Mail, Natural Reader), or that have put themselves into the Task Scheduler (Avast, Crystal Disk Info)So, I thought - What if I put all of my Startups (or as many as possible) into a BAT file, and then not use the Startup folder - because disabling the BAT file, by renaming it with a . I figured out how to do it.
Details: At log on of any user . THIS IS THE FIX. DON'T RUN THE BAT FILE DIRECTLY. No improvement seen- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CONCLUSIONI can get the programs to launch, but it looks like there's something about launching them from the . You use a text editor, and just rename it to Startup.