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 tcf (toggle 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 “tcf” in /usr/local/bin and type “chmod a+x tcf”.
1 2 3 | sudo vi /user/local/bin/tcf |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #!/bin/sh # uppercase any filenames with lowercase chars for file in $* do if [ -f $file ] then tcfile=`echo $file | tr '[:lower:][:upper:]' '[:upper:][:lower:]'` if [ $file != $tcfile ] then mv -i $file $tcfile fi fi done |
1 2 3 | sudo chmod a+x /user/local/bin/tcf |
Uses:
1 2 3 4 5 6 7 | $ tcf OR $ tcf [ ...] |
Chage all file in a folder:
1 2 3 | $ tcf `ls *` |