/* Move file to another Google Drive Folder Arguments: - fileID: id of file to be moved - destFolderID: id of the folder to which the file will be moved Source: https://www.labnol.org/code/20201-move-file-to-another-folder */ function moveFileToAnotherFolder(fileID, destFolderID) { var file = DriveApp.getFileById(fileID); // Remove the file from all parent folders var parents = file.getParents(); while (parents.hasNext()) { var parent = parents.next(); parent.removeFile(file); } DriveApp.getFolderById(destFolderID).addFile(file); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter