Home / GitHub Page

Importing markdown file from command line


#1

With that issue, I explained I would like to create note, without having to open the app.
After thinking of this and with the last comment, I’d loved to see a possibility to do something like this

   ./Joplin --import /path/to/the/markdown/folder
   ./Joplin --importfile /path/to/the/markdown/file/foobar.md

that way, with the scheduler of our OS, we could add notes from various sources.


#2

Seconded. I’d also thought about how to push notes into Joplin, and the command line seems like the best option.


#3

You can already do this with the command line tool:

$ joplin help import
import <path> [notebook]

    Importer des données dans Joplin.

    --format <format>  Format de la source : auto, jex, md, raw, enex
    -f, --force        Ne pas demander de confirmation.

As a general rule, there’s a lot of scripting you can do with the CLI - import, export, create, edit and delete notes, or directly set properties of notes via the set command.


#4

If I remember well our exchanges, the command line tool joplin is a command for the terminal version with shell mode, not the desktop one ?

Because when I run

./Joplin-1.0.93-x86_64.AppImage help import

that opens the desktop app and no help :slight_smile:

As you said earlier many times, the terminal version does not allow to access to the same notes of the desktop one.
So If I want to trick,

  • I install the terminal version
  • make a symbolic link (on linux ) that will use the same data folder of the desktop app
  • I set a crontab (on linux too)

(I’m breaking down open doors but just to be sure and sharing ideas)


#5

Yes the CLI app is separate and cannot directly act on the profile of the desktop app. You would need to set the desktop and CLI app to sync to the same target, then whenever you make a change via the CLI app they will appear in the desktop app too. Just make sure you run joplin sync once you’ve made your changes.

In theory you can make both the CLI and desktop app use the same profile via the --profile flag, but in practice it would cause issues if both apps are modifying the same profile at the same time so it’s not recommanded.


#6

I understand

I made a test like this:

  • I start joplin desktop , and add some folder/notes
  • I start joplin terminal like this
joplin --profile ~/.config/joplin-desktop

and now I’m able to find the notes I made with joplin desktop

I noticed your warning, but I do not plan to use the both at the same times.
That way, that solution avoids to waste disk space. And @ work, as I do not sync anywhere, that should not be a big deal.

@ home I will be able to schedule job to create note ; without opening joplin desktop and the opposite too :slight_smile:

Finally I could redo my “technological watch” (I put in standby) by grabbing news from RSS feeds and create joplin notes :smiley:


#7

If the two apps aren’t open at the same time it would indeed work, and there’s no risk of conflicts.

On a future version, there will be an option to run a local Joplin server that can accept a note and add it directly to a notebook. This is basically to support the web clipper but it can also be used to easily add a note in scripts. I’ve got a working prototype already, just need to clean it up a bit.


#8

That’s awesome; it did occur to me, but I didn’t dare even hope. And you’ve done it already. :clap:t2: :bowing_woman:t2:


#9

Made a test of using joplin (terminal/desktop) with my personal notes, it’s fun and great . :slight_smile:
I will test to create notes from rss feeds


#10

Do you use a script for that? (Reading RSS, transforming into note, importing.) If yes, it would be awesome, if you could share that.


#11

Spoiler alert :grin:

It’s working pretty well already but as always it’s in the details and edge cases that there’s still more to do.


Grab a page/article from web to joplin for creating new notes
#12

that iz ah ho some :smiley: :+1:


#13

I make a django app to be able to add feeds to the database then with a crontab launch a command that will read the url, download rss ; put article in joplin.


#14

How do I import a note along with other resources?
E.g. I want to import a note that references some image and I’d like for the image to also be imported. I’ve tried the naive approach (with the image saved right next to the note), but that didn’t work.


#15

Currently importing resources only work with Enex files. For other format, it would have to be done manually, for example using the “attach” command.


#16

Ah. :frowning: Bummer.

Consider it a feature request, then. :innocent: :pray:t2:


#17

made this https://github.com/foxmask/jong - I need to test the import at least.
otherwise this gives:

jong-load
opening cvs file
reading cvs file
importing ...  foxmask blogz https://foxmask.net/feeds/all.rss.xml  1
importing ...  sam et max blog http://sametmax.com/feed/  1

then create the md file by

jong-run
starting ...
reading foxmask
Creating MD file named  sfr-8-mois-de-calvaire
Creating MD file named  migrer-de-evernote-vers-joplin
Creating MD file named  tableau-comparatif-d-outils-de-prise-de-notes-partie-2-boostnote-vs-joplin
Creating MD file named  tableau-comparatif-d-outils-de-prise-de-notes
Creating MD file named  aparte-avec-horizon-zero-dawn
Creating MD file named  quand-fabric-refuse-de-bosser
Creating MD file named  2017-at-a-glance
Creating MD file named  coverage-install-upload-results
Creating MD file named  retour-sur-des-clients-mastodon
Creating MD file named  fabric-et-la-contrib-django-pour-acceder-a-tous-vos-joujoux
You don't have set the joplin path, then later, you will need to enter yourself
joplin import /home/foxmask/DjangoVirtualEnv/joplin-notegen/jong/jong/import/ blogz
reading sam et max
Creating MD file named  trier-un-csv-de-5-go-13-recently-updated
Creating MD file named  13558-go-de-rames-25
Creating MD file named  do-you-rotate-2
Creating MD file named  introduction-aux-extensions-python-avec-cffi-16
Creating MD file named  les-critiques-des-orm-sont-a-cote-de-la-plaque-38
Creating MD file named  monter-son-master-node-interzone-itz-21
Creating MD file named  le-point-sur-les-crypto-monnaies-36
Creating MD file named  goldenshower-sera-coupe-faute-de-miners-11
Creating MD file named  nicehash-pump-up-your-power-a-quoi-ca-sert-et-comment-ca-marche-8
Creating MD file named  tutorial-pour-miner-du-bitcoin-gold-btg-49
You don't have set the joplin path, then later, you will need to enter yourself
joplin import /home/foxmask/DjangoVirtualEnv/joplin-notegen/jong/jong/import/ blog

#18

@laurent :

with “jong” i wrote that process:

  • grab feeds
  • for each item i create a file
  • once all files are created I import them with joplin import

In that process I loose the title of each article, i have to change it, to be able to add a readable title in joplin, the one of each article just after creating the file, with

joplin import my_import_folder/article-name.md News
joplin set article-name title "my long title"

But is it the right way ? or joplin uses the first line of the article-name.md file as the title ?

I have the same question about every “set” properties in fact :slight_smile:
I would like to set the author and the source_url too, but I’m not sure I have to use

joplin import my_import_folder/article-name.md News
joplin set article-name title "my long title"
joplin set article-name author "foxmask"
joplin set article-name source_url "http://url/to/the/article"

?

May be the best question is: for joplin, how the content of a markdown has to be ?

eg (like pelican static blog)

title: foobar is toto in french
author: foxmask
summary: a long description
date: 2018-05-20 12:00 
tags: foo, bar
slug: foobar-is-toto-in-french
source_url: http://somwhere/over/the/rainbow

# my heading 

the content in markdown

#19

@foxmask, currently the title is simply the filename without the extension, and the note content is the full content of the file.

If you need more control, you either need to use the set command as you’re already doing, or import in the “raw” format. Raw format is simply the format used for synchronisation so it can have all the supported properties (but it might be more complicated to create).

Here’s an example note in “raw” format:

The note title

The note body - it can span multiple lines

And have multiple paragraphs

Then additional metadata can be added after a two line breaks:

id: 1e23028857cb46c082ce6628d4053854
parent_id: 8f4b9330b96240f28ef918c263074dfe
created_time: 2017-12-07T21:24:05.509Z
updated_time: 2017-12-07T21:24:05.624Z
is_conflict: 0
latitude: 48.73219094
longitude: -3.45966339
altitude: 0.0000
author: 
source_url: 
is_todo: 1
todo_due: 0
todo_completed: 0
source: joplin
source_application: net.cozic.joplin
application_data: 
order: 0
user_created_time: 2017-12-07T21:24:05.509Z
user_updated_time: 2017-12-07T21:24:05.624Z
encryption_cipher_text: 
encryption_applied: 0
type_: 1

#20

ok, thanks.

I will just do 4 joplin commands, 1 joplin import and 3 joplin set.

the result is fun :slight_smile: