I want to delete all folders, subfolders and files older than ome day in a specific directory and leave one folder untouched with the forfiles like the command below:
forfiles /p "C:\path\tocheck" /s /m *.* /c "cmd /c for /d %%i in (C:\path\tocheck\\*) do if /i not "%%~nxi"=="foldernottobedeleted" rd /s /q "%%i"" /D -1
The command above deletes everything except the one file I want to keep included and the files that are new, it skips the /d parameter.Where am I wrong?