Everything will be fine. This is the best way to delete old files and recursively delete empty directories. the following .bat file,
forfiles /p [PATH] /s /m [FILE-PATTERN] /d -[DAYS] /c "cmd /c del @path" for /f "delims=" %%d in ('dir [PATH] /s /b /ad ^| sort /r') do rd "%%d"
Placeholders should be replaced as follows (without quotes):
[DAYS] = Max. age of the files in days, eg "10" [PATH] = Path to search for old files and empty folders, eg "C:\Backup\" [FILE-PATTERN] = Pattern that matches files to delete, eg "*.bkp"
The script has been successfully tested on Windows 7 and Windows Server 2003.
sathish anish Oct 07 '17 at 6:20 2017-10-07 06:20
source share