javascript - List all files with sizes in Google Drive -
I try to create a Google Apps script to list all files in size and email them I am here Partially practicing this and maybe it's my code so far:
function list all files () {var rootFolder = DocsList.getRootFolder (); Var content = rootfoldergate files (); Var file = DocsList.getAllFiles (); (I = 0; i & lt; content.length; i ++) {logger.log (file [i] .getName () + ":::" + file [i] .getSize ()); } Var recipient = session .getActiveUser (). GetEmail (); Var topic = 'A list of files in your Google Drive'; Var body = logger.getlag (); MailApp.sendEmail (recipient, subject, body); } It only sends lists about 5 files, as long as I can not convert "contents.length" to manual number like 100. (For some reason too, if I make it something higher like 1000). Anyway I know that I should not use hard numbers. Please follow my ignorance, I am now learning Google scripts about 1 second and about 2 months of my own Javascript. <> Li>
DocsList.getAllFiles () is limited to MAX_RESULT_SIZE ... GetAllFilesForPaging (number, token) Use if you have many files You can only upload all files Try
function list ALLFiles () {// DriveApp is recommended instead of Docs List To var dFiles = DriveApp.getFiles (); While (dFiles.hasNext ()) {var thisFile = dFiles.next () Logger.log (thisFile.getName () + ":::" + thisFile.getSize ()); } // If you have a lot of files, you have to restart it ... var recipients = session.getActiveUser (). GetEmail (); Var topic = 'A list of files in your Google Drive'; Var body = logger.getlag (); MailApp.sendEmail (recipient, subject, body); }
Comments
Post a Comment