home *** CD-ROM | disk | FTP | other *** search
- echo off
- echo.
- echo ┌────────────────────────────────────────────────────┐
- echo │ Delete a directory with all its files │
- echo │ By Prof. Timo Salmi, ts@chyde.uwasa.fi, 22-Jan-91 │
- echo └────────────────────────────────────────────────────┘
- echo.
-
- if "%1"=="" goto _help
-
- rem Change the directory-name parameter to upper case
- set _stash=%path%
- path %1
- set _dir=%path%
- path %_stash%
- set _stash=
-
- rem Checks
- if "%_dir%"=="\" goto _isroot
- if not exist %_dir%\nul goto _notexist
- if not exist %_dir%\*.* goto _nofiles
-
- rem The deletion process
- cd %_dir%
- cd
- echo Delete the files from directory %_dir%
- del *.*
- if exist *.* goto _err1
- cd ..
- echo Break to quit, any other key to remove directory %_dir%
- pause > nul
- rmdir %_dir%
- if not exist %_dir%\nul echo Directory %_dir% has been deleted
- goto _out
-
- :_isroot
- echo Deleting the root directory %_dir% is not allowed
- goto _out
-
- :_notexist
- echo Directory %_dir% not found
- goto _out
-
- :_nofiles
- echo No files in directory %_dir%
- goto _out
-
- :_err1
- echo Warning: Some or all files in %_dir% still remain
- echo Directory still exists
- cd ..
- goto _out
-
- :_help
- echo Usage: DELDIR [DirectoryName]
- echo.
- echo ╔═════════════════════════════════╗
- echo ║ Be extra careful with this one. ║
- echo ║ See the contents and make sure ║
- echo ║ you understand what is done. ║
- echo ╚═════════════════════════════════╝
- echo.
- echo If you get an "Out of environment space" message, increase your
- echo environment space by using shell configuration in config.sys:
- echo Example: shell=c:\bin\command.com /e:1024 /p
- echo.
-
- :_out
- set _dir=
- echo on
-