BASH-script to replace UUID's (in OpenCms or Magnolia)

In content management systems like OpenCms or Magnolia you often run into the problem of having to replace UUID's.
I wrote a little BASH-script for that.


import info.magnolia.importexport.DataTransporter
import javax.jcr.ImportUUIDBehavior
import groovy.io.FileType

def list = []
def dir = new File('/home/marc/c3/eos/EOS_01112018/')
dir.eachFileRecurse (FileType.FILES) { file ->
  list << file
}

list.each {
  path = it.path
  fileName = it.name
  print 'fileName = ' + fileName
  // currently path may not contain "(" and "."
  int indexOf = fileName.lastIndexOf(" (")
  if (indexOf < 0) indexOf = fileName.indexOf(".")
  workspace = fileName.substring(0, indexOf)
  println ' workspace = ' + workspace

hm = ctx.getJCRSession(workspace)
workspaceRoot = hm.getRootNode()
    
xmlFile = new File(path)
DataTransporter.importFile(xmlFile, workspace, '/', false,
ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW, true, true) 
}

I'd be happy to hear from you to support you in any Magnolia (CMS) or OpenCms project as a freelancer (Freiberufler).