Clean Directory – wipe an entire directory structure


@echo off
::CLEANDIR.BAT
::USAGE - CLEANDIR DIRNAME
::This will delete all files and subdirectories on an NT/2000 system.

If not "%OS%"=="Windows_NT" goto DOSEXIT

if /i %1$==$ GOTO :NOPARAM
if not exist %1\. GOTO :NOTFOUND %1
Call :CLEAN %1
GOTO :EOF

:CLEAN
Echo This will DELETE ALL FILES and SUBDIRECTORIES in %1!!!
Echo Press any key to continue or CTRL-Break and terminate the batch file.
PAUSE >NUL
echo.
echo Deleting Files in %1
for /f "tokens=*" %%i in ('dir %1 /b /x /a-d') do @del "%1\%%i"
echo Deleting Directories in %1
for /f "tokens=*" %%k in ('dir %1 /b /x /ad') do @rmdir /s /q "%1\%%k"
GOTO :EOF

:NOPARAM
Echo Missing Parameter
Echo Usage: cleandir directory-path
Echo example: cleandir c:\temp
Echo Put long directory names in quotes " " and do NOT use a trailing \
Echo.
GOTO :EOF

:NOTFOUND
Echo Directory Not Found
Echo Can't find or verify %1
Echo.
GOTO :EOF

:DOSEXIT
ECHO.
ECHO This program requires Windows NT or Windows 2000
ECHO.
GOTO :EOF


Related Posts:

  • No Related Posts

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>