I want to find text files by their name and then get their contents and make them into a var.
I have tried to find the file by its name, but it doesn't seem to work. I'm clueless as to how to find the file contents though.
My code to find the file:
function testThing() {
var findquestions = DriveApp.getFilesByName('tempquestions.txt')
Logger.log(findquestions)
}
I want it to log what it found, but the output is nothing but: "FileIterator". I don't know what that means.
As you can see in the documentation,
.getFilesByName
returnfileiterator
. What's a file iterator? The documentation statesThere may be large amount of files with the same name. This iterator provides access to all those files.
What methods provide access to
file
fromfileIterator
? Thismethod
does.How to get contents of such file? Get
blob
fromfile
andgetDataAsString
fromblob