1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #!/bin/bash # # Shell script to rename given file names to from uppercase to # lowercase OR lowercase to uppercase # # Copyright (C) 2005 nixCraft project. # # This script licensed under GNU GPL version 2.0 or above # # Support/FeedBack/comment : http://cyberciti.biz/fb/ # ------------------------------------------------------------------- # To rename file uppercase to lowercase create sym link: # ln -s /path/2upper /path/2lower # ------------------------------------------------------------------------- # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. # ------------------------------------------------------------------------- FILES="$1" ME="$(basename $0)" # function to display message and exit with given exit code function die(){ echo -e "$1" exit $2 } # exit if no command line argument given [ "$FILES" == "" ] && die "Syntax: $ME {file-name}\nExamples:\n $ME xyz\n $ME \"*.jpg\"" 1 || : # scan for all input file for i in $FILES do # see if upper to lower OR lower to upper by command name [ "$ME" == "2upper" ] && N="$(echo "$i" | tr [a-z] [A-Z])" || N="$(echo "$i" | tr [A-Z] [a-z])" # if source and dest file not the same then rename it [ "$i" != "$N" ] && mv "$i" "$N" || : done |

2 comment
Hi,
I need a script that will copy 360 files starting from run_1_00001.cbf to run_1_00360.cbf to a new directory while changing all of the files to include the word peak just prior to the file extension. For example run_1_00001.cbf changed to run_1_00001peak.cbf and placed in another directory.
how to use this? can use for rename all files in a folder?