Case insensitive file name search and replace

I am trying to find case insensitive file names and then replace that particular file with other name.

if [ -f `find -iname *update* -type f -printf "%f\n"` ]
then
        ls  | grep -i "update" | xargs -I {} mv {} LineItems.csv
        echo "File moved from *update*"
elif [ -f `find  -iname *priority* -type f -printf "%f\n"` ]
then
        ls  | grep -i "priority" | xargs -I {} mv {}  LineItems.csv
        echo "File moved from *priority*"
else
        echo " LineItems file doesnt exist"
        exit 1
fi

Original File name is PRioriTY.csv.. should be changed to LineItems.csv..
but always its going inside the first loop of update.

I guessing you are using find only for the case insensitive option and you are not really interested in files within sub-directories of the current location.

With bash you could achieve this with:

#!/bin/bash

for file in *
do
   case "${file,,}" in
      *priority*)
               mv "$file" LineItems.csv
               echo "File moved from *priority*"
               break ;;
      *update*)
               mv "$file" LineItems.csv
               echo "File moved from *update*"
               break ;;
   esac
done

The reason I use break above is that if you have two or more matching files in your folder all but the last one processed will be lost. Break causes only 1 file to be moved to LineItems.csv at a time, the presumption here is that LineItems.csv is then copied elsewhere or processed in some way, before this loop is called again.

With a shell that doesn't support ${var,,} you could try these alternatives:

   case "$file" in
      *[Pp][Rr][Ii][Oo][Rr][Ii][Tt][Yy]*)
small_name=$(echo $file|tr '[A-Z]' '[a-z]')

case "$small_name" in
     *priority*)

~