Created
April 20, 2012 13:49
-
-
Save ramsesoriginal/2428821 to your computer and use it in GitHub Desktop.
BAT: delete Files in folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set folder=X:\ | |
set filemask=*.log | |
set daysToKeep=20 | |
set command="del" | |
set runOnDays=WED,SUN | |
set runOnTime=23:00:00 | |
set taskname=deleteLogs | |
if "%1"=="-skipTask" GOTO afterCreateTask: | |
schtasks /Create /sc weekly /D %runOnDays% /ST %runOnTime% /tn %taskname% /tr "\"%~fn0\" -skipTask" /F | |
:afterCreateTask | |
forfiles /p %folder% /s -m %filemask% /d -%daysToKeep% /c "cmd /c %command% @path" | |
@echo on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment