home *** CD-ROM | disk | FTP | other *** search
- echo off
- rem This is a subroutine which safedel.bat calls by calling itself
- rem Thus a second batch file is not needed
- rem The subroutine deletes a sigle file
- if not "%2"=="recurse" goto _begin
- :_loop1
- set _reply=
- ask Delete %1 (y or n)? /d /u
- if errorlevel==89 if not errorlevel==90 set _reply=yes
- if errorlevel==78 if not errorlevel==79 set _reply=no
- if "%_reply%"=="" echo
- if "%_reply%"=="" goto _loop1
- if "%_reply%"=="yes" del %1
- set reply=
- goto _out
-
- rem The "actual" safedel.bat starts here
- :_begin
- echo.
- echo ┌───────────────────────────────────────────────────┐
- echo │ Safe delete of files │
- echo │ By Prof. Timo Salmi, ts@chyde.uwasa.fi, 13-Apr-92 │
- echo └───────────────────────────────────────────────────┘
- echo.
-
- if "%1"=="" goto _help
-
- rem Check that safedel.bat is available at path or current directory
- set _found=no
- if exist safedel.bat set _found=yes
- for %%d in (%path%) do if exist %%d\safedel.bat set _found=yes
- if "%_found%"=="no" goto _err1
-
- rem Check that ask.exe is available at path or current directory
- set _found=no
- if exist ask.exe set _found=yes
- for %%d in (%path%) do if exist %%d\ask.exe set _found=yes
- if "%_found%"=="no" goto _err2
-
- rem Handle the files
- :_loop
- if not exist %1 goto _err3
- rem for MsDos earlier than 3.3 move the rem below one command downwards
- rem for %%f in (%1) do %comspec% /e:1024 /c safedel1 %%f
- for %%f in (%1) do call safedel %%f recurse
- shift
- if not "%1"=="" goto _loop
- goto _out
-
- :_err1
- echo You must have safedel.bat at your path (or the current directory)
- goto _out
-
- :_err2
- echo You must have ask.exe at your path (or the current directory)
- goto _out
-
- :_err3
- echo File(s) %1 not found
- goto _out
-
- :_help
- echo Usage: SAFEDEL [FileName1] [FileName2] [FileName3] ...
- echo.
- echo Wildcards are allowed in the file names.
- echo.
- echo If you get an "Out of environment space" message, increase your
- echo environment space by using shell configuration in config.sys:
- echo MsDos 3.30 example: shell=c:\bin\command.com /e:1024 /p
- echo.
- echo To use this batch you need ask.exe and safedel1.bat either at
- echo your path or the current directory.
- echo.
-
- set _found=
- :_out
-