Converting ODT and RTF Files IN PLACE For Use In Obsidian

I recently discovered Obsidian as a knowledge organizer, and adore it. (Sorry, Joplin, you’ve been replaced.)

It primarily uses "future-proof" markdown formatting (it’s largely plain text and can be viewed/edited by most any program), lets you see your stuff, search and find it easily, does not mess with your existing file structure (and in fact works with it), and has a bazillion plugins that extend its functionality to let you use it for anything from mind maps, organize financial documents, plan a novel (or campaign), and interact with most about any file you have.

With two glaring omissions: ODT (Open Document Text) and RTF (Rich Text Format) files.

I mentioned that Obsidian primarily uses markdown, which I approve of. Images can easily be previewed (sometimes requiring a free plugin that’s easily installed from within the app), and there are plugins to preview DOCX data. {1} But not ODT and RTF files. (At least, not that I found.)

While RTF is an older format and less widely used, I’ve been using LibreOffice and OpenOffice for decades, and still do. The ODT format is widely used and supported, so its omission both in the core functionality and in community plugins is surprising. (While UNITADE allows seeing any file in your vault as a note, it does not provide a preview.)

It might be possible to adapt the DOCXer plugin using the node-odt library instead of the docx-preview node library, but figuring that out is waaaaaaaay outside my current skill set.

So instead, I did something that, IMHO, is better.

I created a BASH script that will take all the ODT and RTF documents in your Obsidian vault (directory), convert them to Markdown, and move the original file to a different archive directory outside of your vault. It checks if the file exists (both the markdown one and the archived one) and automatically adds a number to the filename if they already exist to avoid overwriting existing data. It also creates a file:// link in each markdown note to the original file. It also removes spaces and some other problematic characters in the OG filename so that the file:// link works correctly.

Under the hood, it uses pandoc for the ODT files, but uses unrtf https://www.gnu.org/software/unrtf/ as well for the RTF files because some of the RTF files I had did not convert properly with pandoc alone. And occasionally there is a bit of strangeness left over behind due to a weird formatting thing in the conversion (see the screenshot below). But since the original file is preserved and linked at the bottom, it made the process pretty easy.

You can find the convert_odt_md_for_obsidian.sh script on GitHub, GitLab, or my personal git repository.

{1} UNITADE will allow Obsidian to recognize that the file is present, but the preview just shows that an ODT is a zipped file container.

Featured Image by Pete Linforth from Pixabay