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对象的列表。 –