Add an On Click script for the button. Add the following code to create a file and move it:
// Store the original file path
var fromDir = services.file.getUserDataApplicationPath();
var fromPath = fromDir + services.file.getSeparator() + "myFile.txt";
// Check whether there is a file to move and create one if not
if (!services.file.existsFile(fromPath)) {
services.file.writeFile(fromPath, "Hello, world.")
}
// Define a destination directory to move the file to.
var destDir = fromDir + services.file.getSeparator() + "myNewDir";
// Define the location for the new file
var destPath = destDir + services.file.getSeparator() + "myMovedFile.txt";
// Check whether the destination directory exists and create it if not
if (!services.file.existsFile(destDir)) {
services.file.createNewDirectory(destDir);
}
// Move the file!
services.file.moveFile(fromPath, destPath);