Importing markdown file from command line

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

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.

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.

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

Ah. :frowning: Bummer.

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

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
2 Likes

@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

@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

ok, thanks.

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

the result is fun :slight_smile:

Here is the results in Joplin once RSS grabbed and created.

at the end of each grabbed article I add the source of the article in the footer

1 Like

Nice project, and an interesting use of Joplin automation!

Thanks !

and that will be a perfect, with your

I really like to see this feature on Joplin Desktop version

I really like to see this feature on Joplin Desktop version

Which one? I think everything mentioned in this thread has been implemented.

1 Like

The feature is to be able to pass commands directly to Joplin Desktop version using the command line tool. I'm using Windows and the command line tools are Command Prompt and Powershell.

it would be like the --profile command you pass on Joplin Desktop to tell it where the data to be read/write.

On Windows Command Prompt, when you tell it to

D:/apps/Joplin/Joplin.exe --import D:/notes/folder archive

Joplin Desktop will import the allowed files of the notes folder to the notebook: archive

Something like the request from @foxmask

Currently you need to use the Terminal version separately to use the command line features.

Right, currently it’s indeed not possible with the desktop version. What do you want to do in particular? Depending on what you want to do, the api could work.

1 Like

Thank you @laurent, I like to import/export using the command line. The import will be used to add multiple notes to specific notebooks in Joplin. and the export will be used for making backups. I think using the command line is more efficient that using the gui for these jobs.

1 Like

Is the API not a viable way for you, then? As long as Joplin is running and the Clipper API is enabled, you could send a request to it (via curl or similar) in the place where you’d want to use the command line import. (That’s basically what I’m doing.)

I'm not too familiar with the API, My idea for the commandline is like the --profile command
something like
c:\Joplin\Joplin.exe --import c:\mdfolder

I have Joplin and the web browser clipper installed. could you share your workflow?

Thank you!

There's not much of a workflow to share, I'm afraid. Basically, I look at the API docs, fiddle in Postman until I have requests that do what I need them to do, then write code that generates the same requests. My project is in C#, so that's what I used. Ends up looking something like this.

So in your case, you could write a script that reads your source folder, then issues a call to the WebClipper API for every item in it, to create the corresponding note. The API is really quite friendly and simple to use.