Moving File to Specific Folder using Google Apps Script
These are 3 sample scripts for moving a file to the specific folder in Google Drive using Google Apps Script.
Sample script 1
In this script, only Drive Service is used.
var sourceFileId = "###";
var destinationFolderId = "###";
var file = DriveApp.getFileById(sourceFileId);
DriveApp.getFolderById(destinationFolderId).addFile(file);
file
.getParents()
.next()
.removeFile(file);
Sample script 2
In this script, only Drive API at Advanced Google services. (In this case, it’s Drive API v2.)
var sourceFileId = "###";
var destinationFolderId = "###";
Drive.Files.update({ parents: [{ id: destinationFolderId }] }, sourceFileId);
Sample script 3
In this script, only Drive API v3 is used.