Convert folder of markdown files into .textbundle files

I want to try Craft, but I have around 1000 notes as .md for Obsidian. I have not been able to find a way to convert them all into .textbundle format in a single operation. Ulysses lets you export a file singly into .textbundle, but not a bunch of files into their own separate .textbundle files.

If I have to manually enter 1000 files into Craft, it’s a non-starter so I’m hoping someone here has a way to do this via Command Line, AppleScript or some other application that I haven’t been able to find yet with my searching.

Don’t know if your programmer-y, but there’s a format spec here:

Looks like it’s basically a package file with the Markdown file and a JSON file, plus things like image assets. Since you probably don’t have any image assets with your existing text-based Markdown files, I would think you could make one JSON file, and then just write some sort of shell script to do the conversion.

Maybe using something like pkgutil?

2 Likes

I looked at Textbundle a few years ago. It looked quite straightforward then - even if you had graphics to add to it.

More people should know about and support Textbundle.

1 Like

I am a programmer, was just hoping I didn’t have to roll something myself.

That’s the curse, isn’t it?

“I know I could do this. I just was hoping I wouldn’t have to do this.”

:smiley:

This really does feel like the sort of utility that should be available somewhere, because it’s (a) so stupidly simple (conceptually), and (b) a potentially-huge barrier to people adopting software that people might like to charge for.

1 Like

It’s a relatively simple spec.

The only potentially hard thing is if you have assets and want to have each markdown file be separate TextBundles. In that case, you’d have to use a markdown parser to figure out which assets are associated with separate files.

If you’re okay with them all being in a single TextBundle,

It’s roughly

mkdir bundle.textbundle
cat '{ "version": 2 }' > bundle.textbundle/info.json
cp -r <folder with md>/ bundle.textbundle/
#.                    ^ this '/' means contents of folder and not the folder itself

Yeah to import into Craft they need to be in their own textbundle. So far 20 minutes with Python has got me most of the way there. Looks like I can finish it out in the next hour or so…when I can find that hour again.

I’ll get the python script up on Github once it’s done. Luckily, I don’t need assets because I don’t store any alongside the markdown files so it should be fairly easy.

1 Like

Wouldn’t you want to zip it up?

Perhaps bake that function into a folder action (or Hazel or KM)? (With the Zip suggestion.)

Compressed is .textpack, which Craft doesn’t support so…nope I just want a bunch of .textbundle files

Craft can import either Text Bundle Files or Markdown Files.

2 Likes

Yes it can, but it looses any links between files if you only import .md files. Links are preserved if you use .textbundle. I spent a few hours yesterday working through the limitations on import to see what was needed to migrate my 1000+ notes into Craft for real testing.

Turns out Bear for macOS you can import a bunch of .md files and then export them as .textbundle which preserves the links. Unfortunately Craft limits imports to 200 files at a time. If a link between files spans those chunks then you loose the link. In a database of 1000+ files…that’s a lot of lost links between content.

Sure the double [[ is still there so you can see the link, but Craft doesn’t recognize it as a link so you’re out of luck with it showing you the link in the UI until you find it and relink it.

2 Likes

Craft uses @ to define a link. In craft when you type [[ it is replaced by @. I wonder if you replaced the [['s with @'s would Craft somehow restore the links? Also the Craft people are planning on removing the 200 note limit soon(as of Nov 23). Maybe if you contacted them they could speed things up.

1 Like

A real pity: Much of the point of it is portability.

1 Like

For those following, Craft now supports imports of 2000 .md files formatted like Obsidian would expect and preserves the links.

3 Likes

There is a solution on windows os, refer to MD 转 TB - 动作信息 - Quicker , but i haven’t tried it.

GitHub - devinhurry/markdown-to-textbundle-for-bear: Convert a bunch of markdown files to textbundle and import to bear note app try this script