based on another post by Tiziano Solignani and myself, here is a script that does the job... Please uncomment the setTrashed
statement when you have it fully tested in the logger.
Don't forget to change the email adress as well.
function DeleteMyJpegs() {
var pageSize = 200;
var files = null;
var token = null;
var i = null;
var ThirtyDaysBeforeNow = new Date().getTime()-3600*1000*24*30 ;// 30 is the number of days
//(3600 seconds = 1 hour, 1000 milliseconds = 1 second, 24 hours = 1 day and 30 days is the duration you wanted
Logger.clear()
do {
var result = DocsList.getAllFilesForPaging(pageSize, token);
var files = result.getFiles()
var token = result.getToken();
for(n=0;n<files.length;++n){
if(files[n].getName().toLowerCase().match('.jpg')=='.jpg' && files[n].getDateCreated().getTime()<ThirtyDaysBeforeNow){
// files[n].setTrashed(true)
Logger.log(files[n].getName()+' created on '+Utilities.formatDate(files[n].getDateCreated(), 'GMT','MMM-dd-yyyy'))
}
}
} while (files.length == pageSize);
MailApp.sendEmail('myMail@gmail.com', 'Script AUTODELETE Jpegs report', Logger.getLog());
}
EDIT : If you prefer to look at the size of the files in your drive, you could modify this do do some math on the jpg's size and other filetypes that take space) quite easily... and delete some files accordingly. This is a example to show how to handle the situation.