DOS Batch - Forfiles - deleting specific file extensions

loadedmind

New member
Local time
1:41 PM
Messages
4
Hey all. I've reviewed several different examples of how forfiles works. To set the stage, I need to automatically remove files with a file extension of .0 followed by numbers that increment and these files would be 7 days or older. Unfortunately, none of the examples or forfiles /? usage explains how to specify what I need done to file extensions that end with .0xxxxx

Here is what I have so far:

Code:
echo on 
rem Remove stats-bin.0* files older than 7 days 
forfiles /p "c:\Program Files\MySQL\MySQL Server 4.1\data" /m stats-bin.0* /c "cmd /c del /Q @file  /d -7 
rem pause
Within the data directory, there are stats-bin.index files, stats.0XXXXX files and others. The goal here is to only remove those files that begin with stats-bin.<numbers>

Currently, this script isn't doing anything. Trying to troubleshoot what I'm doing wrong here. If anyone has another forum they frequent for Windows script-specific help, I'd appreciate it (if this isn't the preferred place to post such a thing).
 

My Computer

OS
Win 7 32-bit
You forgot closing quotes for cmd part.
Code:
forfiles /p "c:\Program Files\MySQL\MySQL Server 4.1\data" /m stats-bin.0* /c  "cmd /c del /Q @file[SIZE=5][B][COLOR=red]"[/COLOR][/B][/SIZE] /d -7 
pause
Have just tested that. Works like a charm!
 

My Computer

Computer type
PC/Desktop
OS
Windows 8.1 ; Windows 7 x86 (Dec2008-Jan2013)
Other Info
"The scale icon at the top right of a post or tutorial is how you can give rep to the member."
Back
Top