目标是从Google Drive获取脚本类型的所有文件,并在一个循环中逐个获取其文本内容。
我的代码是:
function searchFiles() {
//https://developers.google.com/apps-script/reference/base/mime-type
var type = MimeType.GOOGLE_APPS_SCRIPT;
var files = DriveApp.getFilesByType(type);
while (files.hasNext()) {
var file = files.next();
process(file);
}
}
function process(file){
//https://developers.google.com/apps-script/reference/base/mime-type
var txt = file.getBlob(PLAIN_TEXT);
Logger.log(txt);
}
从file.getblob()得到的错误是:
Converting from application/vnd.google-apps.script to application/pdf is not supported.
我也试过祭祀
file.getUrl()
但是,如果我以匿名方式打开文件,那么这也只会给出文件的整个HTML,如果我是在登录&错误页HTML的同一窗口中打开的。
是否可以在谷歌应用程序脚本中获取脚本文件的文本内容?