Home / GitHub Page

Import (first line as title)

Is it possible to add a setting to use the first line as title if i import a markdownfile?

I have a bunch of .md files named like 1.md 2.md 3.md but the title is always in the first line of the files.

greetz

Not at the moment. For now your only option would be scripting: either you remove the title from the file and rename the file as TITLE.md. Or you use the API and import the files that way, but again it would require some scripting.

1 Like

@b1n4ryj4n

I know it depends on how many notes you are importing as to whether this is useful, but if you create a new note by copying your markdown to the clipboard and then shift-insert or ctrl-v into a new note it will use the first line as the title. You cannot right-click and paste, you have to shift-insert or ctrl-v.

I provide the above not as a part of the Joplin team but just as a user (Win10 x64 Joplin 1.0.160) who pasted using this method and accidentally found the title was auto-populated.

Update:
In fact if you then delete the first line out of the note (before moving onto a new note and “fixing” the title in place) it will change the title content to the text of the next line in your pasted note that has text in it. In all cases so far it has also stripped out markdown at the start of that line of text (like # or ##) and truncated the title at about 80 characters.

1 Like

@b1n4ryj4n

I have just re-read your question and realised that what I mentioned is going to be of little use to you because if you are already going to be pasting in the body text, note by note, only not having to paste in the title as well is not really going to save any time. Apologies.

1 Like

I started to write a python script for that now because i don’t have time to edit this large number of .md files manually.

Did not see the API for Joplin and now i can easy connect my python tool with Joplin that makes it so much easier.

If any of you get a script working, feel free to create a post with it here, and we can add it to the Apps forum. It can be useful to other users.

sure this is my script i used to import my markdown files with the first line as title,
it’s not optimized because i wrote it very fast and for some reason the is_todo import don’t work with the api or i interpreted the api wrong but for my purpose is works fine.

2 Likes

What Laurent meant was: could you create a new topic not a comment?

We will then move your topic to the Apps category. So just create a topic called “script to import (first line as title)” with the following text:

Import Markdown files to Joplin with first line as title.

Usage:
  md_file_import.py <path_to_md_files> [--is_todo]
  md_file_import.py (-h | --help)
  md_file_import.py --version

Options:
  -h --help     Show this screen.
  --version     Show version.
  --is_todo     Are markdown files todos or not.

Link to your snippet.

We could do that as well, but then the post is not attributed to you.

This has been added recently and will be in the next release.

1 Like

ok done