Find and Replace pattern in lowercase

I have an xml file. I need to convert a particular pattern to lower case and add 1 to it. For example my sample values in file are:

ergeAAwrgersc_DWSTAGE_AC_DBO_TBL_GROUPZONES_INITIAL.badAAergerg
sc_DWSTAGE_AC_DBO_TBL_SECTIONDEPENDENCY_INITIAL.badeAAwrgewrg
sc_DWSTAGE_AC_DBO_TBL_CONTENT_INITIAL.badewrgAAerg

Basically, the pattern is sc_DWSTAGE_.*.bad

I need to convert these to lower case ie. and remove initial and add 1 to it:

ergeAAwrgersc_dwstage_ac_dbo_tbl_groupzones1.badAAergerg
sc_dwstage_ac_dbo_tbl_sectiondependency1.badeAAwrgewrg
sc_dwstage_ac_dbo_tbl_content1.badewrgAAerg

Sed AWK?

 awk 'BEGIN{FS=OFS="."}{sub(/_INITIAL/,"1",$1);t=tolower($1); print t,$2}' urfile 

Hi

sed 's/_INITIAL/1/'  file | tr '[:upper:]' '[:lower:]'

Guru.

Other that you would have to convert back the the `AA' in places like `ergeAAwrgersc' or `badewrgAAerg' since those should stay uppercase.

sed 's/_INITIAL/1/'  file | tr '[:upper:]' '[:lower:]' | sed 's/aa/AA/g' > alfredo123wants.result

Quite convoluted!

There is no OFS..this is an xml file. I apologize I should have mentioned that before. Only the pattern that I am looking for needs to be changed to lower case atleast.

---------- Post updated at 01:18 PM ---------- Previous update was at 01:14 PM ----------

This changes the whole file to lower case. I only need the pattern sc_DWSTAGE_<XYZ>INITIAL.bad to be changed to lower case: sc_dwstage<xyz>1.bad

So for example:

sc_DWSTAGE_AC_DBO_TBL_CONTENT_INITIAL

would need to change to:
sc_dwstage_ac_dbo_tbl_content1.bad

#!/bin/bash

declar -i i
i=1
while read -r LINE
do
  case "$LINE" in
     *"sc_DWSTAGE_"*)
        end="${LINE##*INITIAL}"
        front=${LINE%%sc_DWSTAGE*}
        middle="sc_DWSTAGE${LINE#*sc_DWSTAGE}"
        middle="${middle%_INITIAL*}$i"
        LINE="${front}${middle,,}${end}"
        ;;
  esac
  echo "${LINE}"
done < "file"

The pattern does not exist in a line per se....it is part of the line...the problem I am having is that the pattern needs to be replaced with another pattern....The previous seems to be just putting it out to a file if i want to...

how do I replace something like

sc_DWSTAGE.*INITIAL.bad

to sc_DWSTAGE_.*1.bad where there can be more characters on the line...

so a sample line would be
<ATTRIBUTE NAME ="Reject filename" VALUE ="sc_DWSTAGE_XYZ_XYZ_XYZ_INITIAL.bad"/>

i want to replace to:
<ATTRIBUTE NAME ="Reject filename" VALUE ="sc_dwstage_xyz_xyz_xyz1.bad"/>