Renaming files with strings from xml tags

Hello!

I need to rename 400+ xml files. The name of the specific file is contained in a xml tag in the file itself.

The batch file should rename all these files with strings found in xml tags.

Every xml file has the following tags:

<footnote><para>FILENAME</para></footnote> 

I have to get the FILENAME from the tag and rename the file with it.

May you possibly help me on the matter?

My system is Windows XP Professional but Linux help will be much appreciated too!

Thanks in advance!

If Perl is available:

perl -ne'
    close ARGV and rename $ARGV, $1 
      if m|<footnote><para>([^<]*)</para></footnote>|
    ' xmlfile1 xmlfile2 ... xmlfilen

Another one with awk:

awk -F "[<>]" '
/<footnote><para>/{f=$5;exit}
END{system("mv " FILENAME " " f)}
' file

Use nawk or /usr/xpg4/bin/awk on Solaris.

Thanks a lot! Works great!