Always read the documentation
Yes, but there is a move function and there isn’t a delete function … so we can go with just a move here rather than an explicit copy and delete. It is just one line of script once you have everything in place.
I’ve put together a little example that walks you through things.
//Set some demo things to work with
const FILENAME = "movethisfile.txt"
const FILE_CONTENT = "just some arbitrary demo content here"
const BASE_PATH = "/"
const FOLDER1 = "Folder 1"
const FOLDER2 = "Folder 2"
const PATH1 = BASE_PATH + FOLDER1 + "/" + FILENAME
const PATH2 = BASE_PATH + FOLDER2 + "/" + FILENAME
//Initialise our iCloud object
let fmCloud = FileManager.createCloud(false);
//Create the folders we'll move the file between
//Write the file into the first folder
//Read the file back from the first folder
//Move the file from the first folder to the second folder
if (fmCloud.moveItem(PATH1, PATH2, true))
//Read the file back from the first folder ... it should come back empty this time
//Read the file back from the second path
alert("File copy failed ... but I don't know why")
function fileInfo(p_intPath, p_strPath)
let fmCloudInfo = FileManager.createCloud();
alert("PATH (" + p_intPath + ") = " + p_strPath + "\n\n---\n" + fmCloudInfo.readString(p_strPath) + "\n---")
Note: I’ve put an if-else in at one point where it doesn’t ‘necessarily’ require it … but that’s just because I’ve noted some odd behaviour in my beta version of the Drafts app and I’d rather you got a warning if the move fails for you in the same circumstances. I’ve dropped Greg a note with some details to see if he can shed any light on it.
If I get chance I’ll have a dig into the Dropbox API for the rpcRequest. I know that a move file is a straight forward request just requiring the full source and destination paths. It’s just a case of getting the paths and it isn’t something I’ve had need to look at before - but that just makes it a more worthwhile excuse to be something I take a look at