home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2254 < prev    next >
Internet Message Format  |  1990-12-28  |  1KB

  1. From: dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi)
  2. Newsgroups: alt.sources
  3. Subject: Re: Neat utility to convert uppercase filenames
  4. Message-ID: <2797@cirrusl.UUCP>
  5. Date: 11 Dec 90 05:44:57 GMT
  6.  
  7. I think all the programs posted so far have the bug that if you have
  8. files called "x" and "X", they will delete one of them.  Here's mine.
  9. Doesn't disturb files whose names already contain any lowercase
  10. characters (thus preserving names like "Makefile"), and even has online
  11. help!  Not shar'd, cut out and use.
  12.  
  13. #! /bin/sh
  14. # converts to lowercase
  15. if test $# -lt 1; then
  16.    echo "usage: lfname file ..."
  17.    echo "(specified filenames are converted to lowercase)"
  18.    exit 1
  19. fi
  20.  
  21. for f in "$@"
  22. do
  23.    case "$f" in
  24.    *[a-z]*)
  25.       #echo "skipping $f, contains lowercase chars"
  26.       ;;
  27.    *)
  28.       newname=`echo "$f" | tr 'A-Z' 'a-z'`
  29.       if test "$newname" != "$f"
  30.       then
  31.      if test -f "$newname"
  32.      then
  33.         echo "$newname already exists"
  34.      else
  35.         mv "$f" "$newname"
  36.      fi
  37.       fi
  38.       ;;
  39.    esac
  40. done
  41. exit 0
  42. --
  43. Rahul Dhesi <dhesi%cirrusl@oliveb.ATC.olivetti.com>
  44. UUCP:  oliveb!cirrusl!dhesi
  45.