我正试图找到一种方法来删除Google驱动器中的多个空子文件夹,但我发现了一个代码,但没有用。
我有多个名为“文件(附加到Project)的文件”的文件夹,每个文件夹中有17个子文件夹(大约2000个),其中一些子文件夹为空。
您能帮我找到正确的方法吗?
function DelEmptySubfolder() {
var folders = DriveApp.getFoldersByName('Files (attached to Project)');
var ss = SpreadsheetApp.create("test1234");
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.setTrashed(true);} }