在我们迁移到团队云端硬盘期间,我们有一个文件夹被迁移了两次。第一次被打断了,我们现在有数千个重复的文件夹,里面什么都没有。我想删除或至少删除特定团队驱动器上完全空的任何文件夹。我在下面找到了一个尝试修改的旧脚本:
function delEmptyFolders() {
var folders = DriveApp.getFolders();
var ss = SpreadsheetApp.create("folderslist");
while (folders.hasNext()) {
var folder = folders.next();
var files = folder.getFiles();
var childfolders = folder.getFolders();
var filecount = 0;
var foldercount = 0;
while (childfolders.hasNext()){
var childfolder = childfolders.next();
foldercount ++;
}
while (files.hasNext()){
var file = files.next();
filecount ++;
}
ss.appendRow([folder.getId(),folder.getName(),filecount, foldercount]);
if (filecount == 0 && foldercount == 0){
folder.setTrashed(true);
}
}
}
我的问题是如何让这个脚本在特定的团队驱动器上运行,或者更好的是,在团队驱动器的特定文件夹中运行?
评论中回答的原始问题 - 下面的新脚本 - 评论中的后续问题
提前感谢您的帮助和我的歉意,因为我在编码或脚本方面经验不足。
function starEmptyFolders() {
var folders = DriveApp.getFolderById('ID').getFolders();
var ss = SpreadsheetApp.create("test");
while (folders.hasNext()) {
var folder = folders.next();
var files = folder.getFiles();
var childfolders = folder.getFolders();
var filecount = 0;
var foldercount = 0;
while (childfolders.hasNext()){
var childfolder = childfolders.next();
foldercount ++;
}
while (files.hasNext()){
var file = files.next();
filecount ++;
}
////////////////////
var child = childfolders;
var subFolders = child.getFolders();
while(subFolders.hasNext()) {
var subFolder = subFolders.next();
var subfoldercount = 0;
subfoldercount ++}
///////////////////////////
}
ss.appendRow([folder.getId(),folder.getName(),filecount, foldercount, subfoldercount,]);
if (filecount == 0 && foldercount == 0){
folder.setStarred(true);