Grab a bunch of document links from Google Drive and convert them to Markdown.
You put a bunch of links in a file, run some make
commands, check your results, and copy the Markdown files wherever you need them.
This is very similar to Goodls, except this uses more readily-available tools and is probably easier to break, lol.
- make
- Curl
- It would be trivial to swap out
curl
forwget
, if you wanted to.
- It would be trivial to swap out
- Bash
- Pandoc
- XeLaTeX
- This is only for PDF previews.
- Pandoc needs to know where XeLaTeX is.
- In Google Drive, go to the file you want to convert, right click it, and choose "Get shareable link".
- You need the drive link, not the docs link. It should look like this:
https://drive.google.com/open?id=1x9sxi3rikPEjh2--X68eALqWpuUHYNjM_IMc1kB4T58
- It's okay to add a comment after the link as long as its separated from the ID with something that
isn't a letter, number, dash, or underscore. So, for example, this would be fine:
https://drive.google.com/open?id=1x9sxi3rikPEjh2--X68eALqWpuUHYNjM_IMc1kB4T58 # K-40 (Mini Laser) SOP (WIP)
- You could technically just put "id=" followed by the file ID, since only strings of the above mentioned characters that follow "id=" are assumed to be Google Drive IDs, but let's not overcomplicate things </irony>.
- You need the drive link, not the docs link. It should look like this:
- Paste that link into SOPlinks.txt
- In the
docsSOPs
directory runmake download
scrapeDocs.sh
will download all the links as DOCX files.- If Google doesn't know how to convert the requested file to DOCX, it'll give you an error.
- The files will have the same name as in Google Drive, but problematic characters -- like spaces and parentheses -- will be removed.
- Everything will go in
downloads/
- To convert the downloaded DOCX files to markdown, run
make markdown
- (Don't change into
downloads
.)
- (Don't change into
- If you want to preview the converted files, run
make pdf
, go into thedownloads/
directory and open them in whatever pdf viewer. - If the converted files look good, run
make deploy
to move them out ofdownloads/
intoTOGO/
.- Note, if files of the same names already exist in TOGO, this will overwrite the existing files.
If you're worried about this, you can check
git status
to see if anything shows up as "modified" rather than "untracked".
- Note, if files of the same names already exist in TOGO, this will overwrite the existing files.
If you're worried about this, you can check
- Move the converted files (and their associated media) from
TOGO/
to wherever you want them. - If you wish, run
make clean
to get rid of the stuff that was downloaded.- Deployed files will not be removed.