home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
RD!.ZIP
/
RD!.CMD
Wrap
OS/2 REXX Batch file
|
1993-03-28
|
3KB
|
83 lines
/*-----------------------------------------------------------------------+
| |
| RD!.CMD - Removes entire HPFS or FAT directory structures. |
| Nothing stands in it's way. |
| |
+-----------------------------------------------------------------------*/
parse upper arg target_dir
say
if queued()>0 then call drainq
if target_dir\='' then do
call wipeout
end
else do
say 'RD! - Remove a directory, and all subdirectories.'
say ' Supports FAT and HPFS. Exercise Caution...'
say
say ' -> SYNTAX: RD! UTILITY'
say ' RD! OS!2 2.0 Desktop'
end
bailout:
exit
Wipeout:
'@CD "'target_dir'" 1>NUL 2>NUL'
if rc\=0 then do
say '->' time()", Target directory dosen't exist."
signal bailout
end
say '->' time()', Resetting attributes.'
'@ATTRIB *.* -R -S -H /S 1>NUL 2>NUL'
if rc\=0 then do
say ' ' time()', Global attribute change failed.'
end
say ' ' time()', Processing directory structure.'
call load_structure
say ' ' time()', Removing files and subdirectories.'
i=1
if words(dir_list)>0 then do i=i+1 until dir_list=''
parse value dir_list with '"'data'"' dir_list
'@DEL "'data'\*.*" /N 1>NUL 2>NUL' /* delete files */
'@RD "'data'" 1>NUL 2>NUL' /* remove dir */
if rc\=0 then do
say ' ' time()', Could not remove:('data').'
end
end
'@DEL *.* /N 1>NUL 2>NUL' /* delete files in 1st level */
if rc\=0 then do
say ' ' time()', Some files in 'target_dir' not removed.'
end
'@CD..' /* surface to base level */
'@RD "'target_dir'" 1>NUL 2>NUL' /* remove 1st level */
if rc=0 then do
say ' ' time()', Task complete,' i 'directories removed.'
end
else do
say ' ' time()', Unable to completely remove' target_dir'.'
end
return
Load_Structure:
file_list='';dir_list=''
/*----------------------------------------------------------+
| /S - All subdirectories. |
| /AD - Only show directory names. |
| /B - Don't include directory header or trailer info. |
| 2>NUL - Send error output (if any) to null. |
| SORT - Sort /R (reverse order) the directory output. |
| RXQUEUE - Pump it onto the stack for REXX to read. |
+----------------------------------------------------------*/
'@DIR /S /AD /B 2>NUL | SORT /R | RXQUEUE'
do i=1 to queued()
parse pull data
if data\='' then dir_list=dir_list '"'data'"'
end
return
drainq:
do queued()
parse pull .
end
return