Answer the question
In order to leave comments, you need to log in
Automatic deletion of files from all Google Drive folders using Google apps script?
Good afternoon! This script automatically deletes files older than n days from folders.
function DeleteOldBackup() {
var Folders = new Array(
'id папки',
' id папки'
);
var Files;
Logger.clear();
for (var key in Folders) {
Folder = DriveApp.getFolderById(Folders[key])
Files = Folder.getFiles();
Logger.log('Открываю папку: ' + Folder.getName());
while (Files.hasNext()) {
var File = Files.next();
if (new Date() - File.getLastUpdated() > 30 * 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