我有以下脚本,当我有超过2000个孤儿时,它恢复了约214个文件,并被发送到新的孤立文件夹。我很感激任何建议
function myFunction(findOrphaned) {
var allFiles = DocsList.getAllFiles();
var orphaned = DocsList.getFolder('Orphaned');
for (var i = 0; i < allFiles.length; i++) {
if (allFiles[i].getParents().length === 0) {
allFiles[i].addToFolder(orphaned);
}
}
}
答案 0 :(得分:0)
我认为这将使用较新的DriveApp API进行您尝试的操作,因为正如rchang指出的那样,DocsList API已被弃用并设置为在4月退役。
function collectOrphans(findOrphaned) {
var folder = DriveApp.getFoldersByName('Orphaned').next();
var files = DriveApp.getFiles();
var orphanCount = 0;
while(files.hasNext()){
var file = files.next();
if(!file.getParents().hasNext()){
folder.addFile(file);
orphanCount++;
}
}
Logger.log('Moved ' + orphanCount + ' orphans successfully.');
}