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 / duplfile.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  71 lines

  1. ############################################################################
  2. #
  3. #    File:     duplfile.icn
  4. #
  5. #    Subject:  Program to find directories with same files
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     June 10, 1994
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program lists the file names that occur in more than one
  18. #  subdirectory and the subdirectories in which the names occur.
  19. #
  20. #  This program should be used with caution on large directory
  21. #  structures.
  22. #
  23. ############################################################################
  24. #
  25. #  Requires:  UNIX
  26. #
  27. ############################################################################
  28.  
  29. procedure main(args)
  30.    local ext, posit, files, names, name, dir, temp, dirs
  31.  
  32.    ext := args[1] | ""
  33.    posit := -*ext
  34.  
  35.    names := table()
  36.  
  37.    files := open("ls -R", "p")
  38.  
  39.    while name := read(files) do
  40.       name ? {
  41.          if dir <- tab(-1) & =":" then {
  42.             next
  43.             }
  44.          else if tab(posit) & =ext then {
  45.             /names[name] := []
  46.             put(names[name], dir)
  47.             }
  48.          }
  49.  
  50.    names := sort(names, 3)
  51.  
  52.    while name := get(names) do {
  53.       dirs := get(names)
  54.       if *name = 0 then next
  55.       if *dirs > 1 then {
  56.          write("file: ", image(name), " occurs in the following directories")
  57.          every write("\t", image(fix(!sort(dirs))))
  58.          write()
  59.          }
  60.       }
  61.  
  62. end
  63.  
  64. procedure fix(s)
  65.  
  66.    /s := "."
  67.  
  68.    return s
  69.  
  70. end
  71.