I'm not a JAVA or Javascript specialist but by googling a bit i found some examples of JAVA code to move a file to a different name using the code below:
var fileToCopy = new Packages.java.io.File("C:/Users/foo/AppData/Local/Temp/changeit.txt");
var NewName = new Packages.java.io.File("C:/Users/foo/AppData/Local/Temp/changeit2.txt");
if (NewName.exists())
throw new java.io.IOException("file exists");
// Rename file (or directory)
var success = fileToCopy.renameTo(NewName);
if (!success) {
// File was not successfully renamed
}
I tried it and it worked fine.