home *** CD-ROM | disk | FTP | other *** search
/ ftp.ncftp.com / ftp.ncftp.com.zip / ftp.ncftp.com / ncftp / older_versions / ncftp-3.2.2-src.tar.bz2 / ncftp-3.2.2-src.tar / ncftp-3.2.2 / sh / fixfcase.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1999-09-29  |  529b  |  31 lines

  1. #!/bin/sh
  2.  
  3. if [ "$#" -eq 0 ] ; then
  4.     dir="."
  5. else
  6.     dir="$1"
  7. fi
  8.  
  9. find "$dir" | awk -F'|' '{
  10.     dir=$0;
  11.     base=$0;
  12.     sub(".*/", "", base);
  13.     i = index(dir, base);
  14.     if (i <= 0) {
  15.         dir="";
  16.     } else {
  17.         dir = substr(dir, 1, i - 1);
  18.         sub("/*$", "/", dir);
  19.     }
  20.     i = index(base, ".");
  21.     if (i > 0) {
  22.         s = tolower(substr(base, i));
  23.         if (substr(base, i) != s) {
  24.             r = substr(base, 1, i - 1);
  25.             base = r s;
  26.             printf("echo /bin/mv \"%s\" \"%s%s\"\n", $0, dir, base);
  27.             printf("/bin/mv \"%s\" \"%s%s\"\n", $0, dir, base);
  28.         }
  29.     }
  30. }' | /bin/sh
  31.