Use ‘tr’ in a shell script to translate text case
This tip is applicable to UNIX / Linux operating systems
‘tr’ is a command line utility which you can use to convert text to UPPER or lower case.
To convert all the letters of the English alphabet found in a string to lower case do this at the UNIX command line:
% sh (to switch to bourne shell)
% echo $string | tr ′[A-Z]′ ′[a-z]′
Pretty simple eh? Now say you have a list of images in a folder and they are all mixed up and you want to get them synchronized. You could use a simple script to do this. Call it ‘convert_to_lowercase.sh’. The contents are:
for file in $list
new_name=`echo $file | tr ′[A-Z]′ ′[a-z]′`
mv $file $new_name
To run the script from the command line enter:
% sh convert.sh
You can also chmod 777 convert.sh if you wish.