Skip to content

How to Change Filenames to UPPERCASE Case in Linux

Many time you may need to change the file or folder name case, for example lower to upper, upper to lower or toggle the case. I am giving you to the best solution to change the folder name case. We need to create a command for easy access. First of all create a script in “/usr/local/bin” folder and give it the execute permission, so any user can access this function as a command. I named this script ucf (upper case file) but you can user your name that you can easily remember and identify.

Note: You need super user privilege.
Create a script and put this script named “ucf” in /usr/local/bin and type “chmod a+x ucf”.

$ sudo vi /user/local/bin/ucf
#!/bin/sh
# uppercase any filenames with lowercase chars
for file in $*
do
if [ -f $file ]
then
ucfile=`echo $file | tr '[:lower:]' '[:upper:]'`
if [ $file != $ucfile ]
then
mv -i $file $ucfile
fi
fi
done
$ sudo chmod a+x /user/local/bin/ucf

Uses:

$ ucf
OR
$ ucf [ ...]

Chage all file in a folder:

$ ucf `ls *`