Last active
April 27, 2023 03:50
-
-
Save wchiquito/5932870 to your computer and use it in GitHub Desktop.
[Google Apps Script] Move files
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
| /* CODE FOR DEMONSTRATION PURPOSES */ | |
| function getFileById_(idFile) { | |
| return DocsList.getFileById(idFile); | |
| } | |
| function getFolderById_(idFolder) { | |
| return DocsList.getFolderById(idFolder); | |
| } | |
| function copyFile_(file) { | |
| return file.makeCopy(file.getName() + '_Copy'); | |
| } | |
| function moveFile_(file, addToFolder, removeFromFolder) { | |
| file.addToFolder(addToFolder); | |
| file.removeFromFolder(removeFromFolder); | |
| } | |
| function main() { | |
| var _folderTarget = getFolderById_('[ID FOLDER TARGET]'); | |
| var _file = getFileById_('[ID FILE TO COPY]'); | |
| var _copyFile = copyFile_(_file); | |
| var _folderSource = _copyFile.getParents()[0]; | |
| moveFile_(_copyFile, _folderTarget, _folderSource); | |
| } | |
| /* CODE FOR DEMONSTRATION PURPOSES */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment