How to convert document from Google Docs to text file

6,689

No need to pipe to other program to convert the file. You can download from Google Docs in any supported format, by using the existing parameters in the URL address.

https://docs.google.com/document/d/FILE_ID/export?format=FORMAT

where:

  • FILE_ID is string ID of target file and;
  • FORMAT is file format of choice i.e. txt

Then, downloading the document from Google Docs as text file is straightforward by using wget or a web browser. Both methods will download the document as text file as expected.

I have tried myself and the output looks something like this:

$ wget https://docs.google.com/document/d/FILE_ID/export?format=txt
--####-##-## ##:##:##--  https://docs.google.com/document/d/FILE_ID/export?format=txt
Resolving docs.google.com (docs.google.com)...
Connecting to docs.google.com (docs.google.com)... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/plain]
Saving to: ‘export?format=txt’

    [ <=>                                    ] 649         --.-K/s   in 0s      

####-##-## ##:##:## (##.# MB/s) - ‘export?format=txt’ saved [649]

The URL address for other products such as Google Sheets, Google Presentation or even Google Drive would be slightly different.

In terms of documentation, the only relevant guide I found was this dated blog post circa 2014. There is this page of developer guide for Google Drive but not useful as it is. That is all.

Share:
6,689

Related videos on Youtube

suomynonA
Author by

suomynonA

Updated on September 18, 2022

Comments

  • suomynonA
    suomynonA almost 2 years

    How would I capture all the text in a document from Google Docs and convert it to a text file, preferably a way that can be used in a script? Would wget work? such as:

    wget https://docs.google.com/document/d/documentcode > googledoc.txt
    

    If so, would I be able to use a shortened URL?