Answer the question
In order to leave comments, you need to log in
How to delete a certain type of files from Google Drive?
There is this script:
function getFilesByDate() {
var arrayOfFileIDs = [];
var ThirtyDaysBeforeNow = new Date().getTime() - 3600 * 1000 * 24 * 7;
var cutOffDate = new Date(ThirtyDaysBeforeNow);
var cutOffDateAsString = Utilities.formatDate(cutOffDate, 'GMT', 'yyyy-MM-dd');
var theFileID = '';
var files = DriveApp.searchFiles('modifiedDate < "' + cutOffDateAsString + '"');
while (files.hasNext()) {
var file = files.next();
theFileID = file.getId();
arrayOfFileIDs.push(theFileID);
Logger.log('ID: ' + file.getId() + ', Name: ' + file.getName());
Logger.log('Дата последнего обновления: ' + file.getLastUpdated());
}
return arrayOfFileIDs;
}
Answer the question
In order to leave comments, you need to log in
To have n days, pass the parameter instead of 7 here
var n = 7;
var ThirtyDaysBeforeNow = new Date().getTime()-3600*1000*24*n;
var files = DriveApp.searchFiles(
'modifiedDate < "' + cutOffDateAsString +
'" and (mimeType = "application/zip" or mimeType = "image/jpg")');
image/jpg
and image/jpeg
, but not a fact. Drive.Files.emptyTrash();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question