Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I was very interrested by patt0's (best) answer and tried to improve it (just a little :-) by adding a few features for my personal comfort...</p> <p>Here is what I came to, just for information (<em>added data logging saved in a single document that won't be deleted so you can keep a trace of what happened - or what will happen if you run it with the commented</em> <code>setTrashed()</code><em>- and sending a mail to you with the log data doc url for easy access)</em></p> <pre><code>function processAllFiles() { var continuationToken = UserProperties.getProperty('DELETE_ALL_FILES_CONTINUATION_TOKEN'); var numberOfFiles = Number(UserProperties.getProperty('Number_of_files_processed')); var thisScriptFileId = DocsList.find("continuationToken = UserProperties.getProperty('DELETE_ALL_FILES_CONTINUATION_TOKEN')")[0].getId(); Logger.log(thisScriptFileId); if(UserProperties.getProperty('logFileId') == null ){ var logFileId = DocumentApp.create('Delete All Files Log data').getId(); var doc = DocumentApp.openById(logFileId); doc.getBody().appendParagraph('List of all the files you deleted\n\n'); UserProperties.setProperty('logFileId', logFileId); } if (continuationToken == null) { var files = DriveApp.getFiles(); var continuationToken = files.getContinuationToken(); UserProperties.setProperty('DELETE_ALL_FILES_CONTINUATION_TOKEN', continuationToken); UserProperties.setProperty('Number_of_files_processed', '0'); } else { var files = DriveApp.continueFileIterator(continuationToken); } while (files.hasNext()) { var file = files.next(); if(file.getId()!=logFileId&amp;&amp;file.getId()!=thisScriptFileId){ // file.setTrashed(true); numberOfFiles++ Logger.log('File '+Utilities.formatString("%05d", numberOfFiles)+' : '+file.getName()); } } var paragraphStyle = {}; paragraphStyle[DocumentApp.Attribute.FONT_SIZE] = 8 ; var doc = DocumentApp.openById(UserProperties.getProperty('logFileId')); doc.getBody().appendParagraph(Logger.getLog()).setAttributes(paragraphStyle); MailApp.sendEmail(Session.getEffectiveUser().getEmail(),'DeleteFiles result Log','Here is the log data to your script :\n\n' +doc.getUrl()+'\n\nExecuted by this script : '+DocsList.getFileById(thisScriptFileId).getUrl()); // finish processing delete the token UserProperties.deleteProperty('DELETE_ALL_FILES_CONTINUATION_TOKEN'); UserProperties.deleteProperty('Number_of_files_processed'); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload