Found a similar thread here: Need java code to convert the page names to lower case which a staff member posted this bit of code:
void rename(Node node, String newName) throws RepositoryException
node.getSession().move(node.getPath(), node.getParent().getPath() + "/" + newName.toLowerCase()); //
which is close to what I need except that when its executed the node structure is changed and the newly named node is pushed to the bottom and I need it to maintain position in the structure.
There is no explicit method to rename node in JCR, It can be done only by move method.
Since move method change the order of node but It can be reorder.
JCR 2.0: 23 Orderable Child Nodes (Content Repository for Java Technology API v2.0)
Thank you the Node.OrderBefore(String srcChildRelPath, String destChildRelPath)
is exactly what I needed.
Yeah there is too many nodes to change manual for us so we us groovy scripts to do so. This code in your link is the same i have posted above. Which apparently is the only way to do it but I have found a way to reorder after the fact.
See this thread here - it may help. I have never tried renaming a node via code.
java - How can you change the name of a JCR node? - Stack Overflow
Hope this helps...