1

I am using a Google Apps Script to list Word files in a folder, however this will work only for .docx files, not .doc. Any idea?

 var folderID = "ID#"
  var sourceFolder = DriveApp.getFolderById(folderID);
  var files = sourceFolder.getFilesByType(MimeType.MICROSOFT_WORD);
  // will list only .docx
1

How about this answer?

Pattern 1:

If you want to retrieve files with the extension of .doc, please modify as follows.

From:

MimeType.MICROSOFT_WORD

To:

MimeType.MICROSOFT_WORD_LEGACY

Pattern 2:

If you want to retrieve files with the extensions of .doc and .docx, please modify as follows.

From:

var files = sourceFolder.getFilesByType(MimeType.MICROSOFT_WORD);

To:

var files = sourceFolder.searchFiles("mimeType='" + MimeType.MICROSOFT_WORD_LEGACY + "' or mimeType='" + MimeType.MICROSOFT_WORD + "'");

References:

If I misunderstood your question and this was not the result you want, I apologize.

  • Works as a charme! Thanks – Riccardo May 17 at 8:08
  • @Riccardo Thank you, too. – Tanaike May 18 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.