I need a batch file to delete folders old of 1 day.
The folders contains inside files that will be removed together with the folders
I tryed 3 different code but do not remove the old folders.
Path where are located folders to delete (path have space):
D:\Programmi Installati\
Example folder names (start with log_)
log_1
log_10-12-2019
log_2008-10000
log_222222211111
Days old: 1
:: Code 1
@echo off
setlocal
set target="D:\Programmi Installati\"
set days=1
for /f "usebackq delims=" %%G in (
'forfiles /p "%target%" /c "cmd /c if /i @isdir == true echo @path" /d -%days% 2^>nul'
) do rd /s /q "%%~G"
pause
endlocal & exit /b
:: Code 2
forfiles /p "D:\Programmi Installati\" /d -1 /c "cmd /c if @isdir==true rd /s /q @path"
:: Code 3
FORFILES /P "D:\Programmi Installati\" /S /C "cmd /c IF @isdir == TRUE rmdir /S @path /Q" -D -1
I'm interested a fix of code already indicate or a new code that works.