Category : Files from Magazines
Archive   : V12N15.ZIP
Filename : TRASH.BAT

 
Output of file : TRASH.BAT contained in archive : V12N15.ZIP

@ECHO OFF
REM ----------------------------------
REM TRASHOUT.BAT - empties C:\TRASHCAN
REM Requires DOS 5.0
REM ----------------------------------
IF NOT '%1'=='' GOTO OneDir
REM Modify the next lines so they switch to the drive
REM and directory that YOU use for batch files.
C:
CD \BAT
IF EXIST TRASHOUT.DAT GOTO AllWell
ECHO The essential file TRASHOUT.DAT is missing.
ECHO %0 cannot function without this file.
GOTO Done
:AllWell
REM Fill DIRLIST.DAT with a list of all directories
REM under C:\TRASHCAN, in reverse sorted order
DIR C:\TRASHCAN /A:D /B /S /-L > DIRLIST.DAT
COPY DIRLIST.DAT ANYLEFT.DAT > NUL
IF NOT EXIST ANYLEFT.DAT GOTO OutOfLoop
SORT /R < ANYLEFT.DAT > DIRLIST.DAT
:===== Loop ==========
COPY TRASHOUT.DAT + DIRLIST.DAT TRASHTMP.BAT > NUL
CALL TRASHTMP
FIND /V "trashout" < TRASHTMP.BAT > DIRLIST.DAT
COPY DIRLIST.DAT ANYLEFT.DAT > NUL
IF NOT EXIST ANYLEFT.DAT GOTO OutOfLoop
DEL ANYLEFT.DAT
GOTO Loop
:===== OutOfLoop =====
DEL DIRLIST.DAT
DEL TRASHTMP.BAT
ECHO Now emptying the TRASHCAN
ATTRIB -R-H-S C:\TRASHCAN\*.* /S
IF NOT EXIST C:\TRASHCAN\*.* GOTO Done
ECHO Y | DEL C:\TRASHCAN\*.* > NUL
GOTO Done
:===== OneDir ========
ECHO Wiping out directory %1
IF NOT EXIST %1\*.* GOTO DirEmpty
ECHO Y | DEL %1\*.* > NUL
: DirEmpty
RD %1
:===== Done ==========