Answer the question
In order to leave comments, you need to log in
Apps script How to empty a folder?
Elementary code
function dellAllFile() {
const tempFolderId = 'тут айди папки'//папка куда сохраняем временные файлы
let files = DriveApp.getFolderById(tempFolderId).searchFiles('title != "nothing"');
while (files.hasNext()) {
let file = files.next();
//Drive.Files.remove(file.getId());// вариант 1
Drive.Files.trash(file.getId());// вариант 2
}
Answer the question
In order to leave comments, you need to log in
Most likely you are deleting other people's files from someone else's folder. Log what is throwing the error
try {
Drive.Files.trash(file.getId());
} catch (err) {
console.log(err.message, file.getName());
}
let files = DriveApp.getFolderById(tempFolderId)
.searchFiles('"me" in owners and title != "nothing"');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question