How To Get Text Content Of Google Apps Script?
the objective is to get all files of SCRIPT type from Google Drive; & in a loop get their text contents one by one. My code is: function searchFiles() { //https://developers.
Solution 1:
Flow:
- Get all script files by MIME
- Get id of each file
- Urlfetch it by Drive REST API or Apps Script API
Script:
function getScriptSourceCode(fileid) {
var params = {
headers: { Authorization: 'Bearer ' + ScriptApp.getOAuthToken() },
followRedirects: true,
muteHttpExceptions: true,
};
var url =
'https://script.google.com/feeds/download/export?id=' +
fileid +
'&format=json';
var response = UrlFetchApp.fetch(url, params);
var json = JSON.parse(response);
for (var file in json['files']) {
Logger.log(json['files'][file]['source']); //Source code
}
}
Post a Comment for "How To Get Text Content Of Google Apps Script?"