我想了解当您选择谷歌驱动器脚本http://www.google.com/script/start/时作为示例列出的 moveFileToFolder 脚本(单击“开始脚本”,然后在“创建脚本”中选择“驱动器”选项“ 菜单)
代码如下。我的问题是如何更改此代码,以便将文件“Austin”移动到文件夹“Texas”中?这是假设文件“奥斯汀”是一个谷歌文档,目前位于我的主谷歌驱动器文件列表中,文件夹“德克萨斯”目前也位于我的主谷歌驱动器列表中。
还有一些关于在驱动器中移动文件的其他帖子,我了解主要概念,但我似乎无法成功获取文件或文件夹 ID。任何帮助非常感谢?
/**
* This script moves a specific file from one parent folder to another.
* For more information on interacting with files, see
* https://developers.google.com/apps-script/class_file
*/
function moveFileToFolder(fileId, targetFolderId) {
var targetFolder = DocsList.getFolderById(targetFolderId);
var file = DocsList.getFileById(fileId);
file.addToFolder(targetFolder);
};