Windows people like pretty filenames....
Our marketing director likes to use as many spaces and capital letters as she can when she names filenames. This may somehow look more aesthetically pleasing to your typical MSer, but if you are a Linux admin who needs to navigate said filenames, it could be a royal pain. I set out to find a solution to this problem and here is my result:
#!/bin/sh
# lowerit
# convert all file names in the current directory to lower case
# only operates on plain files--does not change the name of directories
# will ask for verification before overwriting an existing file
for x in `ls`
do
if [ ! -f $x ]; then
continue
fi
lc=`echo $x | tr '[A-Z]' '[a-z]'`
if [ $lc != $x ]; then
mv -i $x $lc
fi
done
for file in *; do mv "$file" `echo $file | sed -e 's/ */_/g' -e 's/_-_/-/g'`; done
Basically, the for loop takes all uppercase letter and converts them to lower case, assuming that lowercase version doesn't exist. The last for loop removes spaces. I just tested this on my home directory(yes, i too sometimes use a capital letter here or there), and it worked like a charm. The script is basically the content from these two sites combined, thank you! http://www.swflug.org/index.php?option=com_content&task=view&id=71&Itemi... http://www.linuxjournal.com/content/convert-filenames-lowercase