Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.
July 26, 1998
Typing RD /S /Q FolderName will delete all files, sub-directories and the FolderName also. If you wish to not remove the target folder, create DELTREE.BAT in your path:
@echo offif {%1}=={} @echo Syntax: DelTree Folder&goto :EOFif not exist %1 @echo Syntax: DelTree Folder - Folder %1 does not exist.&goto :EOFpushd %1if %ERRORLEVEL% NEQ 0 @echo Syntax: DelTree Folder - Folder %1 does not exist.&goto :EOFdel /q /f "*.*"for /f "Tokens=*" %%i in ('dir %1 /B /A /AD') do rd /s /q "%%i"popd
To delete all the files and sub-directories in My Test Folder, type:
DELTREE "My Test Folder"
You May Also Like