0
我有一堆谷歌文檔,我想連接成一個新的新文檔。基本上我想要做的Unix命令相當於:我需要將文本文檔1,2,3連接成4.如何?
貓的1.txt 2.txt 3.txt> 4.txt
我似乎無法找出從做到這一點的最好辦法Apps腳本文檔。會有人碰巧知道嗎?
我試過如下:
// ... code omitted
var entries = [];
while (files.hasNext()) {
var file = files.next();
var name = file.getName();
if (file.getOwner().getName() != 'My Name') continue
var re = /Pattern I am looking for - \d\d/g;
if (name.match(re) == null) continue;
entries.push({"Name" : name, "File" : file});
}
entries.sort(function(a,b) { return a.Name.localeCompare(b.Name); });
// Open the Full.txt file and add each file into it in sequence.
var fullDoc = DocumentApp.create('Full.txt');
entries.forEach(function(e) {
var contents = e.File.getAs('text/plain');
// Haven't yet gotten to sticking contents into the target file
// because content retrieval itself fails with the message:
// "Converting from application/vnd.google-apps.document to text/plain
// is not supported. (line 51, file "DocMerge")"
return;
});
感謝。
-av
添加更多關於您的搜索/研究工作的詳細信息。參考[問]。 –
我想試試[DocumentApp](https://developers.google.com/apps-script/reference/document/document-app)[Body Class](https://developers.google.com/apps-script/) (https://developers.google.com/apps-script/reference/document/body#getText())與[DriveApp's](https://開發人員)相關聯,也許可以使用[getText()](https://developers.google.com/apps-script/reference/document/body#getText() google.com/apps-script/reference/drive/drive-app)file [setContent()](https://developers.google.com/apps-script/reference/drive/file#setContent(String)) –
There似乎並不是一種從文件中獲取身體的方法。我擁有的是File對象的列表。 –