Answer the question
In order to leave comments, you need to log in
Delete files only from folders older than n days in Google drive?
Good afternoon! This script looks at all files older than n days and deletes them.
function DeleteOldBackup() {
let Files = DriveApp.getFiles()
while (Files.hasNext()) {
const File = Files.next()
Logger.log(File.getName())
if (new Date() - File.getLastUpdated() > 25 * 24 * 3600 * 1000) {
File.setTrashed(true);
Drive.Files.remove(File.getId());
Logger.log('File ' + File.getName() + ' удалено');
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question