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 lcf (lower 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 “lcf” in /usr/local/bin and type “chmod a+x lcf”.
1 2 3 | sudo vi /user/local/bin/lcf |
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 lcfile=`echo $file | tr '[:upper:]' '[:lower:]'` if [ $file != $lcfile ] then mv -i $file $lcfile fi fi done |
1 2 3 | sudo chmod a+x /user/local/bin/lcf |
Uses:
1 2 3 4 5 6 7 | $ lcf OR $ lcf [ ...] |
Chage all file in a folder:
1 2 3 | $ lcf `ls *` |