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

  1. From: flint@gistdev.gist.com (Flint Pellett)
  2. Newsgroups: alt.sources
  3. Subject: Re: Neat utility to convert uppercase filenames
  4. Message-ID: <1034@gistdev.gist.com>
  5. Date: 10 Dec 90 19:44:11 GMT
  6.  
  7. jay@gdx.UUCP (Jay A. Snyder) writes:
  8.  
  9.  
  10. >Did you ever do mget from simtel20 or ymodem batch downloads from an MSDOS
  11. >BBS, and get a lot of uppercase files in your directory?
  12.  
  13. >Well this is a utility that will take all specified files and convert
  14. >them to lower case.
  15.  
  16. >One exception is that trailing .Z's will be left uppercase
  17.  
  18. Rather a bit of overkill to write a C program for it isn't it?
  19. The script below, hacked out in about 30 seconds, does most of what
  20. want-- adding an -if- to check for the trailing .Z files is left
  21. as an exercise for the reader :-).  You can also add a check for
  22. a $1 that was already all lower case if you want.
  23.  
  24. #!/bin/ksh
  25. while [ -n "$1" ]
  26. do
  27.     typeset -l LC="$1"
  28.     mv "$1" "${LC}"
  29.     shift
  30. done
  31.  
  32. I suppose I should offer a (slower) Bourne shell version for
  33. anyone unlucky enough to still be limited to that:  I'm 
  34. sure someone can probably improve on this and make it even
  35. shorter. (You can probably write it in perl in 1 line.)
  36.  
  37. #!/bin/sh
  38. while [ "$1" != "" ]
  39. do
  40.     mv $1 `echo $1 | tr "[A-Z]" "[a-z]"`
  41.     shift
  42. done
  43. -- 
  44. Flint Pellett, Global Information Systems Technology, Inc.
  45. 1800 Woodfield Drive, Savoy, IL  61874     (217) 352-1165
  46. uunet!gistdev!flint or flint@gistdev.gist.com
  47.