I have a script that reads files from a folder and catalogs the contents to a spreadsheet. To avoid duplicates I want to move the files to a different folder (file.addToFolder(newFolder)) which works, however when I try to file.removeFromFolder(formerFolder) I get “cannot find method” which would suggest I am not giving it the right class of object even though removeFromFolder is listed as a member of the File class.
function moveFileToFolder(fileId, targetFolderId,formerFolderId) {
var targetFolder = DocsList.getFolderById(targetFolderId);
var file = DocsList.getFileById(fileId);
file.addToFolder(targetFolder);
file.removeFromFolder(formerFolderId);
};
What am I doing wrong?
You should get the
formerFolderlike you get thetargetfolderand pass it to the method instead of theformerFolderId.