Hi everyone.
I'm in need of a solution where i need to rename a folder to a name that's inside an XML file in that folder.
OS is Ubuntu 9.10 with Gnome.
I've tried using grep, sed and xpath, but can't seem to find a solution.
This is the simplified folder structure:
FOLDER-NAME
- desc.xml
- other files...
The script will be called with the full path of the folder in the first argument (from nautilus-actions in gnome).
eg: /path/to/script/rename.sh /path/to/folder
The script should read the containing desc.xml file and look for the <ProjectName> tag.
Simplified version of the desc.xml file:
<Project>
<ProjectName>SOME-PROJECT-NAME_A_B_C</ProjectName>
</Project>
Eventually the folder should be renamed to "SOME-PROJECT-NAME".
Note that the text is trimmed from the first char to the first _ (underscore).
The closest i've come is to get the SOME-PROJECT-NAME_A_B_C name, but don't know exactly how to strip it to SOME-PROJECT-NAME and eventually rename the folder that way.
Any help would be much appreciated!
Greetings.