# 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.
# -------------------------------------------------------------------------
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
   # 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" || :
🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source, and DevOps topics via:

Category List of Unix and Linux commands
Disk space analyzers df duf ncdu pydf
File Management cat cp mkdir tree
Firewall Alpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilities bat exa
Network Utilities NetHogs dig host ip nmap
OpenVPN CentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Manager apk apt
Processes Management bg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searching ag grep whereis which
User Information groups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPN Alpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • send2us Jul 6, 2009 @ 14:56

    how to use this? can use for rename all files in a folder?

  • Reginald McNulty Oct 8, 2009 @ 18:36


    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.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum