File and file content string rename

We have around 1000 scripts in a specific folder like mcx001.txt, mcx002.txt, mcx999.txt, mce001.txt etc
We need to rename those files where 3rd character is "x" and should be replaced by "y".
So files should be renamed to mcy001.txt, mcy002.txt, mcy999.txt

Also, mcx001.txt have content "filename=mcx001" which also needs to be renamed to "filename=mcy001".
This applies to all the files which have 3rd character as "x".

Any attempts / ideas / thoughts from your side?

for i in *w*.txt; do mv -v "$i" $(echo "$i" | tr 'w' 'd'); done 

something like this?
and using sed to replace the content?

There's no w nor d in your first specification - I reckon you mean x and y ? And, you don't seem to care for the character position, a w in any position will make that respective file a candidate for the modifications.

How about

awk '
FNR == 1        {print "rm " FILENAME > "remove_old_files.sh"
                 sub ("x", "y", FILENAME)
                }
/filename=/     {sub (/=.*/, "=" FILENAME)
                 sub (".txt", _)
                }
                {print > FILENAME
                }
' ??x*.txt

If happy with the results, run / source the remove_old_files.sh script (after having set the correct permissions, of course)

Thanks!
I did not understand below
print "rm " FILENAME > "remove_old_files.sh"

Did you look into the resulting file?
You want to remove the respective files after they have been modified and written to the new file names.