home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
lansystk.zip
/
MPTSUTIL
/
APPLETS
/
CASRXRM.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1998-05-08
|
3KB
|
142 lines
/* Stripped by STRIPRX.EXE */
rxrm:
parse arg cmdline
rmrc = 0
NO = 0
YES = 1
CALL RxFuncAdd 'SysLoadFuncs','REXXUTIL','SysLoadFuncs'
CALL SysLoadFuncs
IF ParseCmdLine(STRIP(cmdline,'b')) THEN
IF glob.fspec.0 > 0 THEN
DO i = 1 to glob.fspec.0
CALL ON ERROR NAME SFTerror
IF IsAmbiguous(glob.fspec.i)=NO | glob.recurse=YES THEN
CALL SysFileTree glob.fspec.i,"STEM","B"
ELSE
CALL SysFileTree glob.fspec.i,"STEM","F"
CALL OFF ERROR
IF STEM.0 > 0 THEN
DO j = 1 to STEM.0
TheLine = STEM.j
PARSE VAR TheLine . . . attribs fname
CALL DoAnErase STRIP(fname,'b'),STRIP(attribs,'b')
END
ELSE
IF glob.quiet = NO THEN
SAY 'rxrm: "'glob.fspec.i'" not found.'
END
RETURN rmrc
SFTerror:
rmrc = 1
RETURN
ParseCmdLIne: PROCEDURE EXPOSE glob. YES NO
parse arg cmdline
glob.prompt = NO
glob.recurse = NO
glob.remro = NO
glob.quiet = NO
glob.fspec.0 = 0
DO WHILE LEFT(cmdline,1) = "-" | LEFT(cmdline,1) = "/"
PARSE VAR cmdline term cmdline
DO i = 2 to LENGTH(term)
c = TRANSLATE(SUBSTR(term,i,1))
SELECT
WHEN c = "Q" THEN glob.quiet = YES
WHEN c = "I" THEN glob.prompt = YES
WHEN c = "R" THEN glob.recurse = YES
WHEN c = "F" THEN glob.remro = YES
OTHERWISE nop
END
END
END
DO WHILE cmdline <> ""
PARSE VAR cmdline ThisSpec cmdline
i = glob.fspec.0 + 1
glob.fspec.i = ThisSpec
glob.fspec.0 = i
END
RETURN YES
DoAnErase: PROCEDURE EXPOSE glob. YES NO rmrc
parse arg fspec,attribs
DoIt = YES
IsDirectory = NO
IF SUBSTR(attribs,2,1) = "D" THEN
DO
IsDirectory = YES
IF glob.prompt=YES THEN
DoIt = DirPrompt(fspec)
IF DoIt = YES THEN
DO
dirspec = fspec
IF RIGHT(dirspec,1) <> "\" THEN
dirspec = dirspec || "\"
dirspec = dirspec || "*.*"
IF glob.recurse = YES THEN
CALL SysFileTree dirspec,"STEM","B"
ELSE
CALL SysFileTree dirspec,"STEM","F"
DO i = 1 to STEM.0
TheLine = STEM.i
PARSE VAR TheLine . . . dattrib dfname
CALL DoAnErase STRIP(dfname,'b'),STRIP(dattrib,'b')
END
daerc = SysRmDir(fspec)
IF daerc <> 0 THEN
DO
IF glob.quiet = NO THEN
SAY "rxrm: Unable to remove directory" fspec". Return code was" daerc"."
rmrc = rmrc + 1
END
END
END
ELSE
DO
IF glob.prompt = YES THEN
DoIt = FilePrompt(fspec)
IF DoIt = YES THEN
DO
daerc = SysFileDelete(fspec)
IF daerc <> 0 THEN
IF daerc = 5 & glob.remro THEN
DO
CALL SysFileTree fspec,"X","F",,"***-*"
daerc = SysFileDelete(fspec)
END
IF daerc <> 0 THEN
DO
IF glob.quiet = NO THEN
SAY "rxrm: Unable to remove file" fspec". Return code was" daerc"."
rmrc = rmrc + 1
END
END
END
RETURN
DirPrompt: PROCEDURE EXPOSE YES NO
parse arg dirspec
DO WHILE queued()
PARSE PULL junk
END
SAY "Remove files in directory" dirspec"?"
PARSE PULL answer
IF LEFT(TRANSLATE(STRIP(answer,'b')),1) = "Y" THEN
RETURN YES
ELSE
RETURN NO
FilePrompt: PROCEDURE EXPOSE YES NO
parse arg fspec
DO WHILE queued()
PARSE PULL junk
END
SAY "Remove file" fspec"?"
PARSE PULL answer
IF LEFT(TRANSLATE(STRIP(answer,'b')),1) = "Y" THEN
RETURN YES
ELSE
RETURN NO
IsAmbiguous: PROCEDURE EXPOSE YES NO
parse arg fspec
IF POS('*',fspec) > 0 | POS('?',fspec) > 0 THEN
RETURN YES
ELSE
RETURN NO