【发布时间】:2020-01-05 22:07:53
【问题描述】:
如何制作脚本来清空 google 团队驱动器垃圾文件夹?如果我在谷歌驱动器中有三个主要文件夹,它会生成三个主要垃圾文件夹。我怎样才能清空所有这些文件夹?
我发现的所有脚本都只能清空我的驱动器垃圾文件夹。
我已经尝试了很多脚本,你可以看到下面的代码
function createTimeDrivenTriggers() {
ScriptApp.newTrigger('emptyThrash')
.timeBased()
.everyMinutes(1)
.create();
}
function emptyThrash()
{
Drive.Files.emptyTrash();
}
// I have also tried the script below
function doGet() {
try{
authorize();
var key = "YOUR DEVELOPER KEY";
var params = {method:"DELETE",
oAuthServiceName: "drive",
oAuthUseToken: "always"
};
UrlFetchApp.fetch("https://www.googleapis.com/drive/v2/files/trash?key="+key, params);
}
catch(error)
{
MailApp.sendEmail("<some email>", "EMPTY TRASH BIN ERROR:<br>"+error);
return;
}
}
function authorize() {
var oauthConfig = UrlFetchApp.addOAuthService("drive");
var scope = "https://www.googleapis.com/auth/drive";
oauthConfig.setConsumerKey("anonymous");
oauthConfig.setConsumerSecret("anonymous");
oauthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken? scope="+scope);
oauthConfig.setAuthorizationUrl("https://accounts.google.com/OAuthAuthorizeToken");
oauthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");
}
【问题讨论】:
标签: google-apps-script google-drive-api