Rename folder with content from a file inside that same folder?
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?
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?
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];
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];