home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxtools.zip / l2s.cmd < prev    next >
OS/2 REXX Batch file  |  1999-04-15  |  1KB  |  44 lines

  1. /* HPFS names to 8.3 converter */
  2. call RxFuncAdd 'SysFileTree', 'RexxUtil', 'SysFileTree'
  3. call RxFuncAdd 'SysPutEA', 'RexxUtil', 'SysPutEA'
  4.  
  5. call SysFileTree '*', list., 'FO'
  6.  
  7. say '0d0a'x||'Processing long file names'||'0d0a'x
  8.  
  9. do i=1 to list.0
  10.     outfile = substr(list.i, lastpos('\',list.i)+1)
  11.     fext = ''
  12.  
  13.     EA = outfile
  14.     if pos('.', outfile) \= 0 then do
  15.     fname = substr(outfile, 1, lastpos('.', outfile)-1)
  16.     fext  = substr(outfile, lastpos('.', outfile))
  17.     end
  18.     else
  19.     fname=outfile
  20.  
  21.     if pos('.', fname) \= 0 | length(fname) > 8 | length(fext) > 4 then do
  22.         if length(fname) > 8 then do
  23.             leng = length(fname) - 2
  24.             fname = substr(fname,1,4)||'~'||substr(fname, leng)
  25.         end
  26.     fname=translate(fname, '_', '.')
  27.         if length(fext) > 4 then do
  28.             fext = substr(fext,1,4)
  29.         end
  30.     call check
  31.         say '09'x left(fname||fext,12) ' <- ' outfile
  32.         '@copy "'outfile'" "'fname||fext'" >nul 2>nul'
  33.     call SysPutEA fname||fext, '.LONGNAME', "FDFF"x||d2c(length(EA))||"00"x||EA
  34.     '@del "'outfile'" >nul 2>nul'
  35.     end
  36. end
  37. exit
  38.  
  39. check: procedure expose fname fext
  40.  
  41. do while chars(fname||fext) \= 0
  42.     fname = substr(fname, 1, length(fname)-1)||d2c(c2d(substr(fname,length(fname)))+1)
  43. end
  44. return