Moving a page in AEM 6.5 Groovy script to a Folder
Hi,
I need to move a page to a folder in groovy script and it does not work.
Instead of moving the Page to a Folder that exists it moves the page to the same original folder with a name archive1, archive2 etc.
I basically want to write in the groovy script the function tha is the same as the move in the AEM Editor

Page srcPage = pageManager.getPage(srcPath)
if (!srcPage) {
return buildResult(lineNo, srcPath, destPath, "ERROR", "Source page not found!")
}
def pageName = srcPage.getName()
try {
if (!dryRun) {
pageManager.move(srcPage, destPath, pageName, true, true, null)
}
return buildResult(lineNo, srcPath, destPath, "SUCCESS", dryRun ? "Would be correctly deactivated and moved" : "Deactivated and moved")
} catch (Exception e) {
return buildResult(lineNo, srcPath, destPath, "ERROR", "Move Error: ${e.message}")
}