如何获取文件及其相应的ID

时间:2016-04-13 03:48:20

标签: google-apps-script

嗨,大家好我一直在考虑做到这一点但最后做得很好,我希望有人可以帮助我。 这是我想要实现的目标:所以我想在myDrive中显示所有文件夹,并在按钮中显示ID,但隐藏ID。因此,当我点击文件夹时,我可以使用getFolderByID方法复制其中的所有文件夹和文件。 我希望你们都明白我想做什么。 感谢

1 个答案:

答案 0 :(得分:0)

获取您拥有的驱动器中所有文件夹的ID -

function getFolderIDs() {
    var folders = DriveApp.searchFolders('"me" in owners');  *// get all the folders with you as owner*
    var foldArr = [];  *//Declare an array*

    while(folders.hasNext()) {   *//Keep looping till the folders are there*
        var folderId = folders.next().getId();  *// Get Id of each folder*
        foldArr.push(folderId);    *//Capture the IDs in the array*
    }

    Logger.log(foldArr)    *//foldArr will contain ID of the all the folders*
}
相关问题