home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / lngfil.cmd < prev    next >
OS/2 REXX Batch file  |  1994-08-30  |  2KB  |  43 lines

  1. /* Find long file names in a specified tree */
  2.  
  3. '@Echo Off'
  4.  
  5. call RxFuncAdd 'SysFileTree', 'REXXUTIL', 'SysFileTree'
  6.  
  7. say 'LongFile - finds non-8.3 files/directories'
  8. say 'cobbled together by: Doug Azzarito'
  9.  
  10. Parse Upper Arg FileSpec                    /* FileSpec is our search spec*/
  11. if FileSpec = '' then signal usage
  12.  
  13. say 'Starting search of:' FileSpec
  14.  
  15. rc=SysFileTree(FileSpec, 'file', 'BSO');    /* search for files & dirs */
  16.  
  17. LongCount = 0                               /* count of long names found */
  18. say file.0 'files to process'               /* tell 'em how many candidates*/
  19. do i=1 to file.0                            /* loop through candidates */
  20.    iName = LASTPOS('\',file.i) + 1          /* iName=index of base name */
  21.    iDot = POS('.',file.i,iName)             /* iDot=index of DOT (if any)*/
  22.    iEnd = LENGTH(file.i) +1                 /* iEnd = index of end */
  23.    if iDot = 0 then iDot = iEnd             /* No dot? set iDot to end */
  24.    if iDot - iName > 8 | iEnd - iDot > 4 then  /* NAME>8 or .EXT > 4=LFN! */
  25.    do
  26.      say file.i                             /* display long file name */
  27.      LongCount = LongCount + 1              /* and increment counter */
  28.    End
  29. end                                         /* end of main loop */
  30. say LongCount 'Long filenames found'        /* tell user how many hits */
  31. return 0                                    /* and go home happy! */
  32.  
  33. Usage:                      /* No parms specified, let's explain ourselves */
  34.   Say 'usage: LONGFILE filespec'
  35.   Say ' where filespec is a wildcard filespec'
  36.   say ''
  37.   say 'LONGFILE will search for any non-8.3 filename in the specified'
  38.   say 'filespec (including subdirs, hidden files, etc).'
  39.   say 'ex: LONGFILE C:\*        searches the entire C: drive for long file names'
  40.   say '    LONGFILE D:\OS2\A*   searches the D:\OS2 tree for long file names'
  41.   say '                         that begin with the letter A.'
  42.   Exit 1
  43.