使用Google Script将Docx转换为Google Doc

问题描述:

我有很多docx文件(〜72个),它们的MIMETYPE是:

I have a lot of docx files ( ~ 72 ) , their MIMETYPE is :

application/vnd.openxmlformats-officedocument.wordprocessingml.document 

并且我想将它们全部转换为GoogleDocument,以便可以在线对其进行编辑,因此我需要它们是

and I want to convert all of them to GoogleDocument so I can edit them online to do so I need them to be

application/vnd.google-apps.document

这可能吗?我已经尝试使用Blob,但没有任何效果,有一种方法可以创建具有相同格式的新Google文档?

Is this possible ? I've tried with blob but nothing works , there is a way to create a new google doc with the same format ?

知道了.

var docx = DriveApp.getFileById("###");
var newDoc = Drive.newFile();
var blob =docx.getBlob();
var file=Drive.Files.insert(newDoc,blob,{convert:true});

{convert:true}对其进行转换.

ps:您需要设置文档名称,因为它不包含在blob中

The {convert:true} convert it .

Ps : you need to set document name since it's not included in teh blob

DocumentApp.openById(file.id).setName(docx.getName());