Answer the question
In order to leave comments, you need to log in
How to collect documents from google drive to google spreadsheet?
Hello, I want to ensure that data is entered into the Google spreadsheet:
1. File name
2. Link to the file
3. Creation
date 4. MimeType (this is Google doc or Google spreadsheet)
5. Creator name
6. Creator mail
Previously, it was only required to enter only google spreadsheets, now - so that google documents are added.
But according to the current code, only tables are unloaded.
function fileInf() {
currentSheet = SpreadsheetApp.getActiveSpreadsheet();
var filesSheet = DriveApp.searchFiles('mimeType="application/vnd.google-apps.spreadsheet"');
var filesDocs = DriveApp.searchFiles('mimeType="application/vnd.google-apps.document"');
var i = 1;
for (i = 1; i <= 500; i++) {
filesSheet.hasNext();
filesDocs.hasNext();
var file = filesSheet.next() || filesDocs.next();
currentSheet.getRange("A"+i).setValue(file.getName());
currentSheet.getRange("B"+i).setValue(file.getDateCreated());
currentSheet.getRange("C"+i).setValue(file.getOwner().getName());
currentSheet.getRange("D"+i).setValue(file.getUrl());
currentSheet.getRange("E"+i).setValue(file.getOwner().getEmail());
currentSheet.getRange("F"+i).setValue(file.getMimeType());
}
}
Answer the question
In order to leave comments, you need to log in
And is it possible, when it will be possible to upload a file type ( apl.../..document or apl.../..spreadsheet) to column F instead of this long file type name - it will only be Google Sheet or Google Document or other simplified names ?
Well, you need to write a check function something like
function typeFile(type){ var t = "Таблица"; var n = "Что то другое"; if(type="application/vnd.google-apps.spreadsheet"){ return t }else{ return n } }
and then in currentSheet.getRange("F"+i).setValue(typeFile(file.getMimeType()));
well, you can also insert the formula instead of setValue and =IMAGE("your_icon_url",3)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question