home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / blkos207.zip / DD.CMD < prev    next >
OS/2 REXX Batch file  |  1993-05-11  |  3KB  |  136 lines

  1. /*DIRDEL.CMD*/
  2. /*copyright (c) C>BLACK,B.STONE, KUTEK 1993*/
  3. /*all rights reserved, USE AT YOUR OWN RISK*/
  4. /*recursive delete utility*/
  5. /*command line utility,not to be used in batch files*/
  6. /*usage: dirdel <drv:dir>  <filespec> < / >   */
  7. /*  " / " parameter specifies to remove the top dir also*/
  8. /*without it it will remove files in the top dir*/
  9. /*and all sub directories, and the sub dirs themselves*/
  10. /* file spec can be used to remove files of a certain type */
  11. /*throughout a tree*/
  12. /*example dirdel c:os2 removes C:\os2 leaving only the empty*/
  13. /*c:\OS2 directory*/
  14. /*example: dirdel c:winos2 removes C:\OS2\MDOS\WINOS2*/
  15. /* example: dirdel c:os2  *.exe removes .exe files from os2 and all subs*/
  16. /*example: dirdel c:os2 / removes entire os2 tree*/
  17. /* dirdel needs to have access to the D.cmd in order to function*/
  18. /*place both in you path*/
  19. /*remove these comments from your working copy*/
  20.  
  21. '@echo off'
  22. blonk=0
  23. fiz=0
  24. fle=''
  25. lut=0
  26. ko=''
  27. ss=rxfuncquery(sysloadfuncs)
  28. if ss=1 then do
  29. call rxfuncadd sysloadfuncs,rexxutil,sysloadfuncs
  30. call sysloadfuncs;end
  31. curr=directory()
  32. cfr=0
  33. arg naa rtz fle
  34. if aa ='' then do
  35. say 'NO INPUT PARAMETERS SPECIFIED PROGRAM ABORTING'
  36. exit
  37. end
  38. if substr(naa,3,1)='\' then do
  39. parse var naa asw'\'asq
  40. naa=asw||asq
  41. end
  42. if naa='/' then rtz='/'
  43. else if rtz\='/' then fle=rtz
  44. if naa='*'|naa='/' then aa=curr
  45. else do
  46. s4=value(noff,naa,'OS2ENVIRONMENT')
  47. 'call d'
  48. aa=value(noff,,'os2environment')
  49. if naa=aa then do
  50.    say 'DIRECTORY DOES NOT EXIST'
  51. exit
  52. end
  53. if aa=''|aa='AA' then do
  54. say 'ABORTING DELETE'
  55. exit
  56. end
  57. 'set noff='
  58. end
  59. 'cd\'
  60. if right(aa,1)\='\'then aa=aa'\'
  61. if fle=''&right(aa,1)='\' & length(aa)=3 & pos(':',aa)\=0 then do
  62. say 'WARNING THIS IS THE ROOT DIRECTORY!!!!'
  63. say 'THE ENTIRE DISK WILL BE DELETED!! PROCEED? (y/N)'
  64. pull ans
  65. if ans\='Y' then do
  66. s=directory(curr)
  67. exit
  68. end
  69. end
  70. a=sysfiletree(aa,dir,dst)
  71. do i=1 to dir.0
  72. parse var dir.i k1 k2 k3 k4
  73. k4=strip(k4,'b')
  74. xxx.i=k4
  75. end
  76. call checkatt
  77. do l=dir.0 to 1 by -1
  78. nn=sysrmdir(xxx.l)
  79. if nn=0 then say xxx.l 'REMOVED'
  80. cfr=nn+cfr
  81. end
  82.  
  83. if cfr=0 then do
  84. if (rc=0)&(rtz\='/')&fle='' then say 'SUB DIRECTORIES REMOVED'
  85. if rtz='/' then do
  86. tt=strip(aa,'T','\')
  87. hh=sysrmdir(tt)
  88. end
  89. if hh=0&fle='' then do
  90.  say 'DIR TREE 'tt' HAS BEEN REMOVED'
  91. exit
  92. end
  93. end
  94. else if fle='' &fiz\=0 then say 'ERROR:DELETE PROCESS NOT COMPLETED'
  95. else if fle\=''&fiz=0 then say 'SPECIFIED FILES REMOVED'
  96. if aa\=curr then s=directory(curr)
  97. exit
  98.  
  99. checkatt:
  100. bb=sysfiletree(aa||fle,'fil','bst','*****',ko)
  101. if fil.0=0 then say 'FILES DO NOT EXIST'
  102. do u=1 to fil.0
  103. parse var fil.u o1 o2 o3 o4
  104. if (pos('D',o3)=2) then iterate
  105. if (pos('H',o3)=3)|(pos('R',o3)=4)|(pos('S',o3)=5) then do
  106. lut =1
  107. if blonk\=1 then iterate
  108. end
  109. do
  110. say 'deleting' o4
  111. o4=strip(o4,'B')
  112. dsc= sysfiledelete(o4)
  113. if dsc>0 then fiz=1
  114. end
  115. end
  116. if blonk\=1&lut=1 then do
  117. say' THERE ARE H, R, OR S ATTRIBUTE FILES IN THE TARGET TREE'
  118. say 'DO YOU WANT TO DELETE THEM NOW(Y/N)?'
  119. cc=sysgetkey()
  120. if cc='Y'|cc='y' then do
  121. blonk=1
  122. ko='**---'
  123. call checkatt
  124. end
  125. else  do
  126. say 'DELDIR ABORTED'
  127. exit
  128. end
  129. end
  130. return
  131.  
  132.  
  133.  
  134.  
  135.  
  136.