In the MarkDown editor I want to convert links like
to resource links like:
What is the easiest way to do this?
Thanks in advance
Hello, and welcome to the forum!
Do you mean you do not yet have the resources in Joplin at all, and would like to add them and then replace the links in your note?
How much technical skill do you have? If I recall correctly, we’ve talked about this recently on this forum and there doesn’t seem to be a user-friendly way to do that just now.
Hi zblesk, thank you for your reply.
I have .md files which contains such links. The image files are somewhere in the …Local/temp dir on Windows.
If I copy and paste the .md file into Joplin, the image links are not converted to resource files.
So I need a final step to convert such links.
Of course I could insert a single image file with drag and drop from the …Local/temp into the Joplin editor which will convert the image into the resources but this is not workable for many files.
Maybe there is a script which can convert the file links to resource links?
But I think there should be an API function in the sources of Joplin which can do such convertion.
Maybe we can use this function for a solution?
I hope you have an idea how we can solve this problem.
it seems to me that no one has a solution for this problem.
Maybe the topic is not clear too?
So thinking about this the main request is:
How can I programmatically put an image file into the resources and get the related resource link?
Can someone provide me with a script to do this or at least a link to a documentation?
Thank you in advance
No, I’m looking for a way to save a simple md file in Joplin as a note.
The problem is that this md file contains a file link like
How can I convert this file link to a real resource link?
That file does not do the trick ?
If not write a script that add the resource, then get the I’d of that resource to include it into the md file in place of the file:/// link
Sorry, I don’t understand your answer.
My question is how do I create this resource ID programmatically?
Input: file on disk -> Output: resource link of the joplin database.
Or as described above there is a normal way to import a md file into Joplin and convert the file links to resource links automatically.
@foxmask is exactly correct
To do what you want you will need to write a script that reads in a file, searches for file links and then uses the joplin api to programmically convert the file resource to a resource ID.
You can see @foxmask 's excellent jong toolkit for examples on how to use the api.
Is it right that the best way to convert a file resource to a resource ID is to write a script with Joplin api?
I think for someone who’s new to Joplin and just wants to import their md files, that’s a bit too much work.
Maybe there should be a feature request to do this when import or paste a md file into the Joplin editor?
By the way, why doesn’t Joplin do this automatically?
That’s right, you should probably use the Joplin api to do that (which I now understand is not what you meant by “programmatically”).
I think it’s just a weird edge case, some people would not want their files to be converted to resources, others do. The implementation ended up that way and unfortunately it seems not that many people use it in your exact use case so this is the way it is. You can go ahead and make a feature request on github (if it doesn’t already exist).
Thank you very much for the clarifying words.