[Techtalk] real life kewl text-processing

Akkana Peck akkana at shallowsky.com
Sat Jan 10 13:56:11 EST 2004


Oh, are short scripts okay?  I have one I use a lot, called
filestolower, to take files with uppercase or part-uppercase
names and lowercase them.

The motivation is that a lot of Windows-oriented devices, such as
digital cameras, and Windows-oriented CDROMs, and a few programs such
as gphoto, tend to create files with names like PICT032.JPG, and it
offends my delicate Unix sensibilities to look at (let alone type)
filenames like that.

Some of the techniques for perl and sed renaming, plus mmv, can
also do this (thanks to all who have posted, especially about mmv
-- this is a great thread!)  But for something you do a lot,
sometimes it's easier to have an easy command that doesn't
require a lot of typing.

So here's my little script.  Run filestolower *.JPG or whatever.

#! /bin/sh

# Translate filenames to lower case,
# since Windows programs always seem to want to make them upper case.

for fil in $* ; do
  newfil=$(echo $fil | tr '[A-Z]' '[a-z]' )
  if [ $newfil != $fil ]; then
    mv $fil $newfil
  fi
done

	...Akkana


More information about the Techtalk mailing list