home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / progs / tabexten.icn < prev    next >
Text File  |  2000-07-29  |  1KB  |  46 lines

  1. ############################################################################
  2. #
  3. #    File:     tabexten.icn
  4. #
  5. #    Subject:  Program to tabulate file extensions
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     March 10, 1998
  10. #
  11. ############################################################################
  12. #
  13. #  This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program tabulates the file name extensions -- what follows the
  18. #  last period in a file name.
  19. #
  20. #  It is designed handle output UNIX ls -R, but it will handle a list
  21. #  of file names, one per line.
  22. #  
  23. ############################################################################
  24.  
  25. procedure main()
  26.    local line, base, ext, dir
  27.  
  28.    ext := table(0)
  29.  
  30.    while line := read() do {
  31.       if *line = 0 then next            # skip blank lines
  32.       line ? {
  33.          if upto(':') then next
  34.          if not tab(upto('.')) then next
  35.          while tab(upto('.'))
  36.             do move(1)
  37.          if &pos > 1 then ext[tab(0)] +:= 1
  38.          }
  39.       }
  40.  
  41.    ext := sort(ext, 3)
  42.  
  43.    while write(left(get(ext), 20), right(get(ext), 6))
  44.  
  45. end
  46.