Delete files older than x days in .bat script in windows :
If anyone needs to delete files older than x days in .bat script in windows, you could use the following command.
forfiles /p "d:\test" /s /m *.* /c "cmd /c Del @path" /d –15
Check below things to run above command successfully :
1) Make sure the “d:\test” is replaced with the correct path in above command.
2) Run above command and if forfiles command not found error occurs then we need to add the “C:\Windows\System32\” to the PATH environment variable because the forfiles command is resides there.
Below is the documentation and example of forfiles:
If you find this post useful. Please comment Thanks :)
No comments:
Post a Comment