Fer*_*cao 2 google-docs google-apps-script
有人有将存储在 Google Drive 中的一批 .docx 文件转换为 Google Docs 格式的经验吗?
我读过Youssef 三年前发布的解决方案,但它不再起作用了。
当我尝试复制该解决方案时,收到以下错误消息:
很抱歉,服务器发生错误。请稍等一下,然后重试。
var docx = DriveApp.getFileById("###");
var newDoc = Drive.newFile();
var blob =docx.getBlob();
var file=Drive.Files.insert(newDoc,blob,{convert:true});
Run Code Online (Sandbox Code Playgroud)
执行停止于docx.getBlob()。
此功能使用一些高级 Drive API,因此要求您在运行脚本之前首先从脚本编辑器启用它们。要实现此目的,请访问:
资源 > 高级 Google 服务... >一直向下滚动到Drive API > 将关闭按钮切换为打开
这是最终的脚本 -
function myFunction() {
var docx = DriveApp.getFilesByName('Dummy.docx').next();
var newDoc = Drive.newFile();
var blob =docx.getBlob();
var file=Drive.Files.insert(newDoc,blob,{convert:true});
DocumentApp.openById(file.id).setName(docx.getName());
}
Run Code Online (Sandbox Code Playgroud)
希望这可以帮助!