Google Docs has a feature that allows you to export a file as a Microsoft Word file. Is there any way to do this for all of the Google Docs files in a directory? I'm happy to do it either with JavaScript running on the server, or something running in Chrome.
Asked
Active
Viewed 2,648 times
1 Answers
9
How about using Google Apps Script for achieving it? Google Apps Script can be used using Chrome browser. How to use Google Apps Script is here.
The sample script is as follows.
Flow of sample script :
- Define source folder ID and destination folder ID.
- Retrieve files with the mimeType of Google Docs from the source folder.
- Each Google Docs file is saved as Microsoft word file to the destination folder.
Sample script :
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")
);
}
}
Note :
- This sample is very simple. So please modify this for your environment.
- If there are a lot of files in the source folder, there is a possibility that the limitation of script runtime (6 min / execution) exceeds.
If I misunderstand your question, I'm sorry. At that time, please tell me.

Tanaike
- 181,128
- 11
- 97
- 165
-
Precisely what I was looking for! – vy32 Oct 24 '17 at 08:29
-
@vy32 I'm happy that I can help you. – Tanaike Oct 24 '17 at 08:35