Script to Edit the file content and create new file

I have a requirement, which is as follows
*. Folder contains list of xmls. Script has to create new xml files by copying the existing one and renaming it by appending "_pre.xml" at the end.

*. Each file has multiple <Name>fileName</Name> entry. The script has to find the first occurance of "<Name>fileName</Name> in the newly generated (filename_pre.xml) and replace that line with "<Name>fileName_pre</Name>".

First part I think i can give a try .. but second part looks tricky...
Any pointer will be of great help.

please give it a try and post what you have tried...