BAT: Delete old files, "forfiles"..

1 post / 0 new
benzzon's picture
BAT: Delete old files, "forfiles"..

ForFiles - Delete files older than 30 Days

FORFILES /P C:\MyPath\ /S /M log*.txt /D -30 /C “cmd /c del @file”

/S - look at subdirectories
log*.xml - that is the file pattern, you could have it be like *.txt for example
/D -30 = files greater than 30 days
/C - thats the command you want to run

*** Make sure to save batch-file as "DOS-text"..

Download (rename to .exe): forfiles