home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / EAGONE.ZIP / EAGONE.CMD
OS/2 REXX Batch file  |  1991-06-22  |  4KB  |  142 lines

  1. /*
  2.   EA remover/browser for entire drive
  3.   by Mike Nice [73565,565]
  4.   June 1991
  5.  
  6.   Did you ever have your EA DATA. SF file on the C: drive grow to over
  7.   a 500 K after installing OS/2 1.3?  The installation procedure added 
  8.   Extended Attributes (EAs) to all .COM and .EXE files on that drive.
  9.   See the file EADAT2.TXT in the MSOPSYS forum for more details.  
  10.  
  11.   Removing EAs manually from all directories is tedious since EAUTIL operates 
  12.   on only one file at a time.  This program will remove EAs from all .COM and
  13.   .EXE files on the specified drive.
  14.  
  15.  Usage: EAGONE d: EaSize
  16.         Where d: is drive to remove Extended Attributes from
  17.         Where EaSize = size of Extended Attributes to remove from 
  18.                        .COM and .EXE files
  19.  
  20.         (Only Extended Attributes of EXACTLY that size will be removed)
  21.  
  22.   To find out the size of EA to remove, go to the \OS2 directory and 
  23.   do a DIR /N.   The .EXE files will have the size of the extended
  24.   attribute as the second number.  This should be a small number,
  25.   about 55 bytes.  Extended Attributes should not be removed from other
  26.   files unless you are know for sure that they are unnecessary.
  27.  
  28.   CAUTION:  These extended attributes do not seem to be necessary under
  29.             OS/2 version 1.3 and below.  There is no guarantee that they
  30.             are not necessary on a future version.  Use this program at
  31.             your own risk.
  32.  
  33.    NOTE:  If you have the Utility SHOWEA (FROM ZNT:PROGRAMMING), 
  34.           you may choose to modify the code below to log all files 
  35.           containg EAs first and browse the logfile to be sure it
  36.           is safe to proceed.  Or out of curiosity to see what other files
  37.           have EA's, use SHOWEA to log only the files which were not
  38.           modified.
  39. */
  40. ARG CMDLINE
  41. SAY "Extra EA remover"
  42. IF LENGTH(CMDLINE)=0 THEN SIGNAL Help
  43.  
  44. PARSE ARG Drive expectedSize
  45.  
  46. IF LENGTH(Drive)\=2 THEN SIGNAL Help
  47.  
  48. IF LENGTH(expectedSize)=0 THEN SIGNAL Help
  49.  
  50. IF (DATATYPE(expectedSize)\="NUM") THEN SIGNAL Help
  51.  
  52. IF expectedSize=0 THEN SIGNAL Help
  53.  
  54. DirListFile="Dir$li$t.DAT"
  55. EALogFile="EAFiles.LOG"
  56.  
  57. Say "Finding Directories on" Drive
  58. "@TREE " Drive "| RXQUEUE"
  59.  
  60. "@if exist "DirListFile " DEL " DirListFile
  61.  
  62. /* Root directory */
  63. CALL LINEOUT DirListFile, drive || "\", 1
  64.  
  65. DO WHILE QUEUED() > 0
  66.   PARSE PULL PathName Dir .
  67.   IF PathName="Path:" THEN DO
  68.     CALL LINEOUT DirListFile, drive || Dir || "\"
  69.     CALL CHAROUT "CON:", '.'
  70.   END
  71. END
  72.  
  73. SAY
  74.  
  75.    /* Close file */
  76. CALL LINEOUT DirListFile
  77.  
  78. /* Check that the input file exists */
  79. IF (STREAM(DirListFile,C,'QUERY EXISTS')="" ) THEN SIGNAL NoFile
  80.  
  81. DirName=LINEIN(DirListFile)
  82. DO WHILE (DirName<>"")
  83.   CALL CleanDir DirName
  84.   DirName=LINEIN(DirListFile)
  85. END
  86. CALL STREAM DirListFile,C,'CLOSE'
  87. SAY "Done"
  88. SAY
  89.  
  90. "@if exist "DirListFile " DEL " DirListFile
  91.  
  92. "@if exist "EALogFile" echo  NOTE:  More Extended Attribute information in " EaLogFile
  93.  
  94. EXIT
  95.  
  96.  
  97.  
  98. CleanDir:
  99. ARG DirName;
  100.  
  101.   SAY "Searching " DirName
  102.  
  103.   /* *********************
  104.            Change next line to 
  105.   "@DIR /N "DirName"*.* 2>NUL | RXQUEUE"
  106.       to see all files.... 
  107.      ********************** */
  108.  
  109.   "@DIR /N "DirName"*.exe " DirName"*.com 2>NUL | RXQUEUE"
  110.   DO WHILE QUEUED() > 0
  111.     PARSE PULL date time size eaSize fileName .
  112.     IF (DATATYPE(eaSize) = "NUM") & (fileName <> "") THEN DO
  113.      IF eaSize > 0 THEN DO
  114.       IF eaSize = expectedSize THEN DO
  115.         fspec=DirName || fileName
  116.         SAY "Removing EA from " fspec
  117.         "@EAUTIL" fspec "nul /s"
  118.         /*  **** LOGGING ONLY *** "@SHOWEA " fspec ">> " EaLogFile  */
  119.       END
  120.       ELSE DO
  121.         fspec=DirName || fileName
  122.         SAY "EA size "eaSize " NOT removed from " fspec 
  123.         /*  **** LOGGING ONLY *** "@SHOWEA " fspec ">> " EaLogFile  */
  124.       END
  125.      END
  126.     END
  127.   END
  128. RETURN;
  129.  
  130.  
  131. NoFile:
  132. SAY "Unable to create/open directory listing file " DirListFile
  133. SAY
  134. EXIT
  135.  
  136. Help:
  137. SAY "Usage: EAGONE d: EaSize"
  138. SAY "       Where d: is drive to remove Extended Attributes from"
  139. SAY "       Where EaSize = size of EA to remove from .COM and .EXE files"
  140. SAY
  141. EXIT
  142.