Try it in test enviroment an backup your data before
Gas
@echo off
:: ================
:: READ THIS FIRST
:: ================
:: delAllinside.cmd
:: * batch script that will delete EVERYTHING: files and subfolders with any name from inside a specific folder
:: * leaving the intact the target_dir
:: * change target_dir to your folders
:: * change debug in off to make the script "active and DANGEROUS"
:: *by Gatone Canali
setlocal
pushd %~d0%~p0
set logfile=%temp%\_dellog.log
:: *** Remove Log File
del /f /q %logfile% >nul 2>&1
set log=^>^>%logfile% 2^>^&1
set echo=echo
:: *** the TARGET FOLDER
:: ***
set target_dir=C:\DOCUME~1\g\IMPOST~1\Temp
:: *** if debug=ON DO NOTHING
:: *** CHANGE TO OFF AND THE BATCH WILL DELETE ALL :)
set debug=on
:: *** output to video/file
set output=video
if /i +%debug%+==+off+ set echo=
if /i +%output%+==+video+ set log=
if exist "%target_dir%" call :_DELALLINSIDE "%target_dir%"
goto :_END
:_DELALLINSIDE
rem *** delete all files folders and subfolders inside a folder
rem ***
if not exist %1 goto :_ERR
echo ++%~f1 %log%
rem *** change disk
(%~d1 %log%)||goto :_ERR1
rem *** change Dir
(cd %1 %log%)||goto :_ERR2
echo Current folder
cd
echo from this: starting to delete
%echo% attrib -h -s -r *.* /s /d %log%
%echo% del /q /f /s *.* %log%
%echo% rmdir . /S /Q %log%
goto :_EOF
goto :_END
:_ERR
echo ERROR: Folder not found %log%
goto _END
:_ERR1
echo ERROR1: Cannot change disk %log%
goto _END
:_ERR2
echo ERROR2: cannot change dir %log%
goto _END
:_END
:_EOF
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62:





by: oBdAPosted on 2009-01-28 at 01:53:26ID: 23484931
For this, you need twop steps:
* delete all folders in the folder
* delete all files in the folder
The script below should do that. It's currently in test mode, it will only display the delete commands it would run otherwise.
Remove the capitalized "ECHO"s to run it for real.
Select allOpen in new window