Solved To delete dated log file using batch script

July 25, 2012 at 06:26:23
Specs: Windows 7
logs will be created for every day as 20120725.txt. I need to keep 7 days log file and i have to delete the rest. some 1 please help how to delete that..

See More: To delete dated log file using batch script

Report •

July 25, 2012 at 09:36:44
✔ Best Answer
Hi...I have used this in the past as it worked for me. I have it delete files 30 days or older from a folder I have. You should test it first before trying it on the real folder. Change the "Z:\YOURDIRECTORY" to point to your Drive and Folder Directory. Change the number 7 below after the "-" to customize your date preference. Hope this helps!

@echo off
forfiles /p Z:\YOURDIRECTORY /d -7 /c "cmd /c del @file"

Report •
Related Solutions

Ask Question