将 Google 个 Docs 文件批量转换为 Microsoft Word
Batch convert Google Docs files to Microsoft Word
Google Docs 具有允许您将文件导出为 Microsoft Word 文件的功能。有没有办法对目录中的所有 Google Docs 文件执行此操作?我很乐意在服务器上使用 JavaScript 运行,或者在 Chrome.
中使用 运行
使用 Google Apps 脚本实现它怎么样? Google Apps 脚本可以通过 Chrome 浏览器使用。如何使用 Google Apps 脚本是 here。
示例脚本如下
示例脚本流程:
- 定义源文件夹 ID 和目标文件夹 ID。
- 从源文件夹中检索 mimeType 为 Google Docs 的文件。
- 每个 Google Docs 文件都作为 Microsoft Word 文件保存到目标文件夹。
示例脚本:
function convertGoogleDocsToMicrosoftWord() {
var srcfolderId = "### Folder ID ###"; // <--- Please input folder ID.
var dstfolderId = srcfolderId; // <--- If you want to change the destination folder, please modify this.
var files = DriveApp.getFolderById(srcfolderId).getFilesByType(MimeType.GOOGLE_DOCS);
while (files.hasNext()) {
var file = files.next();
DriveApp.getFolderById(dstfolderId).createFile(
UrlFetchApp.fetch(
"https://docs.google.com/document/d/" + file.getId() + "/export?format=docx",
{
"headers" : {Authorization: 'Bearer ' + ScriptApp.getOAuthToken()},
"muteHttpExceptions" : true
}
).getBlob().setName(file.getName() + ".docx")
);
}
}
注:
- 这个示例非常简单。所以请根据您的环境修改它。
- 如果源文件夹中文件较多,有可能the limitation of script runtime (6 min / execution)超出
如果我误解了你的问题,我很抱歉。到时候请告诉我。
Google Docs 具有允许您将文件导出为 Microsoft Word 文件的功能。有没有办法对目录中的所有 Google Docs 文件执行此操作?我很乐意在服务器上使用 JavaScript 运行,或者在 Chrome.
中使用 运行使用 Google Apps 脚本实现它怎么样? Google Apps 脚本可以通过 Chrome 浏览器使用。如何使用 Google Apps 脚本是 here。
示例脚本如下
示例脚本流程:
- 定义源文件夹 ID 和目标文件夹 ID。
- 从源文件夹中检索 mimeType 为 Google Docs 的文件。
- 每个 Google Docs 文件都作为 Microsoft Word 文件保存到目标文件夹。
示例脚本:
function convertGoogleDocsToMicrosoftWord() {
var srcfolderId = "### Folder ID ###"; // <--- Please input folder ID.
var dstfolderId = srcfolderId; // <--- If you want to change the destination folder, please modify this.
var files = DriveApp.getFolderById(srcfolderId).getFilesByType(MimeType.GOOGLE_DOCS);
while (files.hasNext()) {
var file = files.next();
DriveApp.getFolderById(dstfolderId).createFile(
UrlFetchApp.fetch(
"https://docs.google.com/document/d/" + file.getId() + "/export?format=docx",
{
"headers" : {Authorization: 'Bearer ' + ScriptApp.getOAuthToken()},
"muteHttpExceptions" : true
}
).getBlob().setName(file.getName() + ".docx")
);
}
}
注:
- 这个示例非常简单。所以请根据您的环境修改它。
- 如果源文件夹中文件较多,有可能the limitation of script runtime (6 min / execution)超出
如果我误解了你的问题,我很抱歉。到时候请告诉我。