The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 03-05-2005
muthukumar muthukumar is offline
Registered User
  
 

Join Date: Feb 2005
Location: Coimbatore, Tamilnadu, India
Posts: 119
Use this script to change case name of all files in the current directory as,


Code:
#!/bin/sh
# Muthukumar
# Script to change name from upper to lower / lower to upper
# <usage> [lower | upper]

if [[ $# -ne 1 ]]
then
  echo "Usage: $0 [lower|upper]"
  exit 1
fi

for file in `find . -type f`
do
  if [[ "$1" = "lower" ]]
  then
    mv $file $(echo $file | tr [[:upper:]] [[:lower:]])
  elif [[ "$1" = "upper" ]]
  then
    mv $file $(echo $file | tr [[:lower:]] [[:upper:]])
  else
    echo "Unknown option $1. Use upper | lower"
    exit 1
  fi
done

exit 0
## END ##

HTH.