2 # To make this Bourne shell script operative apply once:
10 echo "====================================================="
11 echo "namedown, Convert file names to lower case and ; to ."
12 echo "By Hannu Hirvonen and Timo Salmi Sun 18-Mar-2001"
13 echo "http://www.uwasa.fi/~ts/ and http://www.uwasa.fi/~hh/"
14 echo "====================================================="
16 echo "Usage: namedown [FILENAME(S)]"
18 echo "Converts file names only. Directory names are not affected"
25 newfile=`basename ${oldname} | tr '[A-Z;]' '[a-z.]'`
26 dirname=`dirname ${oldname}`
27 newname="${dirname}/${newfile}"
28 oldname="${dirname}/`basename ${oldname}`"
29 #Don't convert a file into itself
30 if [ "${newname}" = "${oldname}" ]; then
32 #Don't convert directory names
33 elif [ -d "${oldname}" ]; then
34 mv "${oldname}" "${oldname}.bak"
35 mv "${oldname}.bak" "${newname:-${oldname}}"
36 # echo "Directory ${oldname} converted to directory ${newname:-${oldname}}"
38 #Don't convert if the file does not exist
39 elif [ ! -f "${oldname}" ]; then
41 #Don't overwrite existing files
42 # elif [ -f "${newname}" ]; then
43 # echo "${oldname} not converted, file ${newname} already exists" 2>&1
44 #Don't move to subdirectories if they happen to exist
45 elif [ -d "${newname}" ]; then
46 # echo "${oldname} not converted, directory ${newname} already exists" 2>&1
49 mv "${oldname}" "${oldname}.bak"
50 mv "${oldname}.bak" "${newname:-${oldname}}"
51 # echo "File ${oldname} converted to file ${newname:-${oldname}}"