Skip to content

Instantly share code, notes, and snippets.

Last active March 12, 2019 05:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Decodes asset names if they contain any encoded chars.
START = "/content/dam"
// renames a node
def renameToDecoded(node)
existingName = node.getName()
decodedName = URLDecoder.decode(existingName, "UTF-8")
// decoded name is not the same as the encoded one.
if (!existingName.equals(decodedName)) {
existingPath = node.getPath()
parentPath = node.getParent().getPath()
newPath = parentPath + "/" + decodedName
node.getSession().move(existingPath, newPath);
println "renamed \"${node.getName()}\" to \"${decodedName}\" at path ${parentPath}"
// you could always save session in batches.. This way is slower, but will save one by one untill it fails.
if(it.isNodeType("dam:Asset")) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment