@echo off rem *** pathToBackupFiles ******************************************************************************************************************** rem This describes the full path to your Windows backup files. rem rem Example: rem If you have set the path to the files to \\nas-storage\backups\myname-PC you would need rem to enter this path PLUS the PC name. This is where the backup files are stored. rem Unfortunately the command FORFILES does not support UNC paths which means that you will have rem to map the UNC path to a network drive first. You can do this by using the command "net" like this: rem rem -----> net use b: \\nas-storage\backups\myname-PC\MYNAME-PC (where b: is a variable network drive letter) rem rem Please double check the path before running the script. The code line for simulating the deletion is rem enabled by default. In order to enable the file deletion you will have to uncomment the line for real deletion rem rem -----> REMEMBER: YOUR FILES WILL BE DELETED PERMANENTLY WITHOUT FURTHER PROMPTING rem ****************************************************************************************************************************************** set pathToBackupFiles=b:\myname-PC\MYNAME-PC set dayToKeepBackups=20 rem *** Enable this for simulating file deletion (dry-run) *********************************************************************************** FORFILES -P %pathToBackupFiles% /D -%dayToKeepBackups% /C "cmd /c IF @isdir == TRUE (echo Deleting @file ... && echo File deletion...)" pause rem *** do the real deletion ***************************************************************************************************************** rem FORFILES -P %pathToBackupFiles% /D -%dayToKeepBackups% /C "cmd /c IF @isdir == TRUE (echo Deleting @file ... && rd /S /Q @path)"