home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
dab.cmd
< prev
next >
Wrap
OS/2 REXX Batch file
|
1994-05-19
|
4KB
|
156 lines
/*
** Delete All But
**
** by Mark Ziller
**
** based on code by Jeff Elkins
**
*/
/* first, setup VRexx calls */
'@echo off'
call RxFuncAdd 'VInit', 'VREXX', 'VINIT'
initcode = VInit()
if initcode = 'ERROR' then signal CLEANUP
signal on failure name E_CLEAN
signal on halt name E_CLEAN
signal on syntax name E_CLEAN
/* Then load Rexx Utility Functions */
CALL RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
CALL RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
/* Give program info */
say 'Delete All But (DAB) by Mark Ziller, 1994'
say
/* if the user didn't pass any arguments, give them an error box */
ARG ext1 ext2 ext3 ext4 ext5 ext6 ext7 ext8 ext9 ext10
IF STRIP(ext1,'B') = '' THEN
DO
msg.0 = 5
msg.1 = 'Usage:'
msg.2 = ' DAB <template1> <...> <template10>'
msg.3 = ''
msg.4 = 'Example:'
msg.5 = ' DAB *.exe *.cmd *.com'
call VDialogPos 50, 50
call VMsgBox 'Delete All But (DAB)', msg, 1
signal CLEANUP
END
t.1 = ext1
t.2 = ext2
t.3 = ext3
t.4 = ext4
t.5 = ext5
t.6 = ext6
t.7 = ext7
t.8 = ext8
t.9 = ext9
t.10 = ext10
file_error.2 = 'Error: File not found : '
file_error.3 = 'Error: Path not found : '
file_error.5 = 'Error: Access denied : '
file_error.26 = 'Error: Not DOS disk : '
file_error.32 = 'Error: Sharing violation : '
file_error.36 = 'Error: Sharing buffer exceeded : '
file_error.87 = 'Error: Invalid parameter : '
file_error.206 = 'Error: Filename exceeds range error : '
/***********************************************************/
/* hide the files to be kept */
/***********************************************************/
DO x = 1 TO 10
ext = t.x
IF STRIP(ext,'B') <> '' THEN
rc=SysFileTree(ext, dir_list, 'F', '*****','**+**')
END
/**************************************************************/
/* pull the files to be deleted into a stem, then delete them */
/**************************************************************/
rc=SysFileTree('*.*', del_file, 'FO', '**-**','*****')
df = del_file.0
fn = 0
/* now show a check list box to let the user select which files to delete */
call VDialogPos 50,50
result = VListBox('Files to be deleted',del_file, 35, 10, 3)
if result = 'CANCEL' then do
/* msg.0 = 1
msg.1 = 'No Files Deleted'
call VMsgBox 'Operation Canceled', msg, 1 */
say 'DAB: Operation canceled. No files deleted.'
signal UNHIDE
end
/* open a window for showing deleted files */
win.left = 20
win.right = 70
win.top = 80
win.bottom = 40
id = VOpenWindow('Deleting files...', 'BLUE', win)
call VForeColor id, 'WHITE'
call VSetFont id, 'TIME', 14
x = 10
y = 900
/* otherwise, delete the files */
do z = 1 to df
rc = SysFileDelete(del_file.z)
if rc = 0 then
text = z || ' : Deleting: ' || del_file.z
else
text = z || ' : ' file_error.rc || del_file.z
call VSay id, x, y, text
y = y - 60
if y <= 0 then do
call VClearWindow id
y = 900
end
end
call VCloseWindow id
say 'DAB: ' df ' files deleted.'
say
/**************************************************************/
/* unhide the hidden files */
/**************************************************************/
UNHIDE:
DO x = 1 TO 10
ext = t.x
IF STRIP(ext,'B') <> '' THEN
rc=SysFileTree(ext, dir_list, 'F', '**+**','**-**')
END
/* end of CMD file */
CLEANUP:
call VExit
exit
E_CLEAN:
call VExit
say 'DAB: Error. Operation aborted.'
say
exit