Info about deletion lies when no items were deleted when dealing with sub-folders
Posted: 29 Jul 2023 03:30
I have this script
Its purpose is to
1] go to C:\q\Corel Draw - CDR Auto-Backup Files\
2] delete all files
3] present a report listing alphabetically all deleted files showing their paths
4] delete all folders
5] preset a report listing alphabetically all deleted folders showing their path
and / or: report a lack of occurrence of deletion process
Unfortunately that last caveat is not working as this script always says
I already got the same problem solved here viewtopic.php?f=3&t=10852 resulting with such script
but this one is for different conditions as its purpose is to delete only files but leave out sub-folders and their content intact
Code: Select all
@echo off
set "ITEMS-IN-THIS-FOLDER-WILL-BE-DELETED=C:\q\Corel Draw - CDR Auto-Backup Files\"
setlocal enabledelayedexpansion
echo. Deleted files at
echo.
echo %ITEMS-IN-THIS-FOLDER-WILL-BE-DELETED%
echo.
echo.
for /r "%ITEMS-IN-THIS-FOLDER-WILL-BE-DELETED%" %%F in (*) do (
echo.
del "%%F" /q
echo %%F
)
echo.
echo.
echo.
echo. Deleted sub-folders at
echo.
echo "%ITEMS-IN-THIS-FOLDER-WILL-BE-DELETED%"
echo.
echo.
for /f "delims=" %%D in ('dir /ad /b /s "%ITEMS-IN-THIS-FOLDER-WILL-BE-DELETED%" 2^>nul ^| sort') do (
echo.
rd "%%D" /s /q 2>nul
echo "%%D"
)
endlocal
pause
cmd /k
1] go to C:\q\Corel Draw - CDR Auto-Backup Files\
2] delete all files
3] present a report listing alphabetically all deleted files showing their paths
4] delete all folders
5] preset a report listing alphabetically all deleted folders showing their path
and / or: report a lack of occurrence of deletion process
Unfortunately that last caveat is not working as this script always says
and / orDeleted files at
Deleted sub-folders at
I already got the same problem solved here viewtopic.php?f=3&t=10852 resulting with such script
Code: Select all
@echo off
set "FILES-IN-THIS-FOLDER-WILL-BE-DELETED=C:\Users\YOUR-USER-NAME\AppData\Roaming\ASCOMP Software\BackUp Maker"
dir /b /a-d "%FILES-IN-THIS-FOLDER-WILL-BE-DELETED%" 1>nul 2>&1
if not errorlevel 1 (
echo. Deleted files at
echo.
echo %FILES-IN-THIS-FOLDER-WILL-BE-DELETED%
echo.
echo.
for %%F in ("%FILES-IN-THIS-FOLDER-WILL-BE-DELETED%\*.*") do (
echo.
echo %%~nxF
del /q "%%F"
)
) else (
echo. There was nothing to be deleted at
echo.
echo %FILES-IN-THIS-FOLDER-WILL-BE-DELETED%
)
pause