del *.*
will only delete files, but not subdirectories. To nuke the contents of a directory, you can use this script:
@echo off
setlocal enableextensions
if {%1}=={} goto :HELP
if {%1}=={/?} goto :HELP
goto :START
:HELP
echo Usage: %~n0 directory-name
echo.
echo Empties the contents of the specified directory,
echo WITHOUT CONFIRMATION. USE EXTREME CAUTION!
goto :DONE
:START
pushd %1 || goto :DONE
rd /q /s . 2> NUL
popd
:DONE
endlocal
The pushd
changes into the directory of which you want to delete the children. Then when rd
asks to delete the current directory and all sub directories, the deletion of the sub directories succeed, but the deletion of the current directory fails - because we are in it. This produces an error which 2> NUL
swallows. (2 being the error stream).
del /?
at the prompt. It'll give you information in how to use the tool. For this case,del *.* /s
would work but don't do it in the wrong directory!rmdir /s /q c:\users\tbrollo\j2mewtk\2.5.2\appdb\RMS
RMS
directory as well, which may not be what was intended. (In fact it is often what I don't want, because then I lose the original timestamp of the directory and any permissions it had.) See my answer for how to remove all of the contents of a directory but leave the directory itself in place.