Windows 7 Forums


Windows 7: DOS Batch - Forfiles - deleting specific file extensions

19 Sep 2011   #1

Win 7 32-bit
 
 
DOS Batch - Forfiles - deleting specific file extensions

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 System SpecsSystem Spec

27 Sep 2011   #2

Windows 8; Windows 7 x86 (Dec2008-Jan2013)
 
 

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" /d -7 
pause
Have just tested that. Works like a charm!
My System SpecsSystem Spec
Reply

 DOS Batch - Forfiles - deleting specific file extensions problems?



Thread Tools



Similar help and support threads for: DOS Batch - Forfiles - deleting specific file extensions
Thread Forum
Solved Batch File that grabs file names from folder to insert into batch file General Discussion
Deleting registry keys with a batch file? General Discussion
Help with file extensions Music, Pictures & Video
Help with Batch file, if statement in a specific time. General Discussion
can't save specific extensions (first problem with 7) General Discussion


All times are GMT -5. The time now is 03:50 PM.


Seven Forums Android App Seven Forums IOS App Follow us on Facebook

Windows 7 Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows 7" and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32