Rename folder with content from a file inside that same folder?

Advanced Renamer forum
#1 : 01/06-22 04:48
T1M3L3SS
Posts: 1
Alright, so i have exactly 73 folders with random names, some with a "metadata.xml" file, that inside contains the name i want to put in the base folder

Example:
mods\842051906\metadata.xml

Inside the file:

<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<name>[Name I Want]</name>
[the rest]

How can i change the big-number folder's name to the mod name in the file inside it?
#2 : 03/06-22 12:08
David Lee
Posts: 1125
You can read lines from a file using the <File Line> tag.
Call the tag from a script using app.parseTags() and extract the name using a regular expression:

xmlFile = "metadata.xml";
tag = '<File Line:3::"' + item.path + item.name +'\\' + xmlFile + '">';
if (fileLine = app.parseTags(tag)) return fileLine.match(/>(.*)</)[1];