Created
October 7, 2018 18:15
-
-
Save nikanos/1173eb94d31369426d990c0c13aa38f0 to your computer and use it in GitHub Desktop.
Clean old files in folder - Windows batch script
This file contains 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 days=%1 | |
SET folder=C:\_FolderToClean_ | |
IF %days%.==. GOTO NoDaysEntered | |
FORFILES /P "%folder%" /D -%days% /C "cmd /c DEL /Q @path" | |
IF ERRORLEVEL 1 GOTO ForFilesError | |
GOTO End | |
:NoDaysEntered | |
ECHO Please enter the number of days | |
GOTO ReturnError | |
:ForFilesError | |
ECHO forfile command retuned an error!!! | |
GOTO ReturnError | |
:ReturnError | |
EXIT /B 1 | |
:End | |
Exit /B 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment