Created
December 30, 2019 14:45
-
-
Save ttsukagoshi/c53f34cde0af81a4ca77fc6dc93f9695 to your computer and use it in GitHub Desktop.
Google App Script (Javascript) to move all files in a particular Google Drive folder to another folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Function to move all files in a particular Google Drive folder to another folder | |
* @param {string} moveFromFolderId - the original Google Drive folder ID from which you want to move the files | |
* @param {string} moveToFolderId - the Google Drive folder ID to which you want to move the files | |
*/ | |
function moveAllFiles(moveFromFolderId, moveToFolderId) { | |
var moveFrom = DriveApp.getFolderById(moveFromFolderId); | |
var moveTo = DriveApp.getFolderById(moveToFolderId); | |
var files = moveFrom.getFiles(); | |
while (files.hasNext()) { | |
var file = files.next(); | |
moveTo.addFile(file); | |
moveFrom.removeFile(file); | |
} | |
} | |
// This one-by-one method takes too much time if you want to move a bulk of files at once. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment