Export TheBrain to Obsidian, a small script

Honestly I just followed @Sander notes on his GitHub page. The key is that you need python3 installed. Which it turns out my modern mac did.

1 Like

Thank you so much for this script! I am a newbie to Python but once I got that installed it worked flawlessly. very grateful

Do you know how to export only one Type of Thought from TB though? For example I have Organizations and Persons as types in TB and I would like to make the same distinction in Obsidian. Unfortunately it appears that I cannot make a selection before I press export. Any ideas?

Good to hear that it still works. But to be honest, it’s been quite a while since I looked into TheBrain (and my script) and I have no idea how to do what you want… :thinking:

Thanks I have solved it differently: in the newer versions of TB the type of thought is a thought in itself, so by using a program like atom.io I could find&replace the [[type of thought]] to a #typeofthought for 16,000 files at once :sunglasses:

Hey Hey, Thank you so much for this script. Sadly it stops working after some files at my end. It gives this error

OSError: [Errno 22] Invalid argument: ‘./obsidian/Um effektiver zu werden stoppe die Zeit fürs Geschirrspüler ausräumen (unter 2 min?).md’

Is there something i can do? I cant really programm and after a google search it seems that maybe the “?” symbol is causing the error? Thanks a lot for your help guys :slight_smile:

Could it be because of the ü Umlaut?
You could try renaming that thought in TheBrain and running the script again.

Yes, it has to do with funky characters in filenames. I had a similar problem with attachments of notes, which had a ? or a : in the filename. You can avoid this by renaming the attachments before exporting from the Brain.
There’s a little helper tool in the Brain under File->Utilities->Perform Data Integrity Scan. It will show all the files which should be renamed to a safe filename

This was a valuable tool. Thanks! I had a problem where a forgotten thought in my Brian data had a name that was hanging up the conversion. Fortunately, the error message in your script helped me find the thought in the JSON files using Atom, and I just deleted it. Everything fine after that!

1 Like

Hello,
I am trying to migrate my TheBrain instance to Obsidian starting with your tool but I have multiple thought with same name that are used to group external file by project like : requirement, specification, technical solution …
your tool is considering name of thought as the unique identifier then when each time another thought with same name is discovered, the replace previous one is replaced.
at the end from 380.000 thought from the brain, I only got 120.000 note which is note that good for me.
any idea I can update the script knowing that i have too many similar name to rename it manually from TB ?
regards

Great work! Hope someone will add it to the Obsidian Importer community plugin!

I can imagine it would be nice to have it up there, but it’s been almost four years since I wrote that script. I don’t have any Brains to convert anymore and I don’t want to upload a faulty script.
If anyone can test it and maybe even update it to cater for problems like thoughts with the same name, that would be awesome.

I know its been a while and I understand that this is a long shot but I wanted to ask if this supported internal non-text files like a .jpg. It looks like it dumps the contents of an internal text file to the obsidian note but doesn’t handle non-text. Ideally it would be nice to write the internal file to an external file and write a link to the file in the note. I just wanted to make sure I am understanding it before I go modifying code.

If you’re still interested I have changed the original code plus an extra script that helps migrate pasted images; jpg, PNG, webp.

Also butchered in a few lines to replace thought characters that can not be used as file names like; * and ? and |.

Also formatted links for use in excalibrain; e.g. “children::” rather than “children:”

Yes, I’m still interested. Can you provide a link?

Thanks.

1 Like

If you like, I can add your link to the top post (I’ll mention it’s yours), so people can easily find it.

1 Like

Let me tidy up and test the file. I had a small meltdown differentiating then adding images that are embedded Vs attached.

To be clear, It is based on @Sander original great script but it requires a tweak with respect to how one’s brain is set up. Tags as files or tags as obsidian tags, what to do with types which are also thoughts, nested types and tags…etc. all a bit more involved that I than I imagined; especially reverse engineering The Brains codification/enumeration. Anyone know of a dictionary that describes the numerical codes in the JSON files exported by the brain?

OK—I have added a try at a migration script, which can be found here.

It is my first attempt at sharing code, and I am no developer. It is based on @Sander 's version with some tweaks.

I have found that how you use The Brain can make a big difference in how you want it migrated. This script almost suits my usage, but I have some amendments to address. My Brains (in all senses) are not big, so I am not sure how it will work with massive Brains.

My ToDo:

  • What to do with Types (use it to create folders for files or convert to tags - I think the latter) - DONE
  • I have YEAR → MONTH > DATES for journaling purposes. These are moved like any other Thought, so I want to migrate them in a structure akin to how I will configure calendar entries in Obsidian (Everyone will have a different use case)

Sorry for the delay, but I added your link to the top post.