home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 6 File / 06-File.zip / isoren10.zip / ISO.cmd next >
OS/2 REXX Batch file  |  2000-09-09  |  3KB  |  118 lines

  1. /* REXX: ISOren.cmd */
  2. /* (c) Thomas Bohn <Thomas@Bohn-Stralsund.de> */
  3. /* based on LOWER.CMD from Kai Uwe Rommel <rommel@ars.muc.de> */
  4.  
  5. Call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  6. Call SysLoadFuncs
  7.  
  8. Arg args
  9.  
  10. If args='' Then Do
  11.   Say
  12.   Say 'Usage: ISO [-sq21] <arg> ...'
  13.   Say
  14.   Say '       -s  include subdirectories'
  15.   Say '       -q  do not print progress messages'
  16.   Say '       -2  translate to level 2 (max. 31, one point)'
  17.   Say '       -1  translate to level 1 (8.3)'
  18.   Say
  19.   Exit
  20. End
  21.  
  22. option = ''
  23. type = '2'
  24. echo = 'V'
  25.  
  26. Do i=1 To Words(args)
  27.  
  28.   opt = Word(args, i)
  29.  
  30.   Select
  31.     When Left(opt, 2) = '-Q' | Left(opt, 2) = '/Q' Then
  32.       echo = 'Q'
  33.     When Left(opt, 2) = '-S' | Left(opt, 2) = '/S' Then
  34.       option = 'S'
  35.     When Left(opt, 2) = '-2' | Left(opt, 2) = '/2' Then
  36.       type = '2'
  37.     When Left(opt, 2) = '-1' | Left(opt, 2) = '/1' Then
  38.       type = '1'
  39.     Otherwise
  40.       Call dirs opt, option, type, echo
  41.   End
  42.  
  43. End
  44.  
  45. Exit
  46.  
  47. dirs: Procedure 
  48.   Arg pattern, option, type, echo
  49.  
  50.   Call files pattern, type, echo
  51.   
  52.   If option = 'S' Then Do
  53.     nBackSl = lastpos('\',pattern)
  54.     cSpec = substr(pattern,nBackSl+1)
  55.  
  56.     Call SysFileTree pattern, 'dir', 'DO'option
  57.     Do i=1 To dir.0
  58.     
  59.       If option = 'S' then
  60.       Call files dir.i'\'cSpec, type, echo
  61.  
  62.     End 
  63.     
  64.   End 
  65.  
  66. Return
  67.  
  68. files: Procedure
  69.   Arg pattern, type, echo
  70.   
  71.   Call SysFileTree pattern, 'file', 'O'
  72.     
  73.   Do i=1 To file.0
  74.  
  75.     base = FileSpec('Name', file.i)
  76.     base = Translate(base, ' ', "'")
  77.     nErw = lastpos('.',base)
  78.     nErw1 = nErw - 1
  79.     nErw2 = nErw + 1
  80.     if nErw > 0 then cName = substr(base,1,nErw1)
  81.     else cName = base
  82.     cName = translate(cName,'_','.')
  83.  
  84.     If type = '2' Then do
  85.       nLenNeu = length(cName)
  86.       if nLenNeu > 28 then nLenNeu = 28
  87.       if nErw > 0 then do
  88.         cErw = substr(base,nErw2)
  89.         new = substr(cName,1,nLenNeu)'.'cErw
  90.       end
  91.       else do
  92.         new = substr(cName,1,nLenNeu+3)
  93.       end
  94.     end
  95.     else do
  96.       nLenNeu = length(base)
  97.       if nLenNeu > 8 then nLenNeu = 8
  98.       cName = translate(cName,'_',' ')
  99.       cName = translate(cName,'_',',')
  100.       if nErw > 0 then do
  101.         cErw = substr(base,nErw2,3)
  102.         new = substr(cName,1,nLenNeu)'.'cErw
  103.       end
  104.       else do
  105.         new = substr(cName,1,nLenNeu)
  106.       end
  107.  
  108.     end
  109.  
  110.     If new \= base Then do
  111.       If echo = 'V' Then say 'Processing: 'file.i
  112.      '@rename "'file.i'" "'new'"'
  113.     end
  114.   
  115.   End
  116.  
  117. Return
  118.