I'm currently evaluating Joplin as a way to manage notes and files for a ~10 people research lab in Marseille, France. We are currently using Evernote but I want something more future-proof and that allows to control where our data is going. The open source aspect is a big bonus in my view too.
We'll start with a Webdav/NextCloud setup on a dedicated server, with a single Joplin profile used by everyone. If this proves too simplistic or not robust enough for syncing to ~15 machines, I'm planning on trying to install a Joplin server with users and shared notes on our Synology NAS, but that would require some time for me to learn how to do it
For now I have installed Joplin 2.6 (latest) on two Mac computers under Big Sur and set up the Webdav/Nextcloud sync. It works well, and now I'm looking at how I could get the ~10,000 notes we have out of Evernote, keeping the notebook organization with minimal manual export/import.
For export, I have made an applescript that exports each Evernote notebook (all 235 of them) as .enex files, as this is the way to do it if I want each notebook to be imported as a distinct notebook in Joplin.
The next step is where I need help. As I understood there is no built-in way to import a directory of .enex files or batch import 235 .enex files, each as a notebook. From what I read on this forum the solution would be to make a shell script that uses the CLI version of Joplin running the desktop profile version (using the --profile option) and import each .enex file.
I managed to install the CLI version of Joplin, but now I'm stuck because I have no idea how to code a shell script. The only examples of shell scripts I could find that use Joplin are quite elaborated, and do something very different from what I want (like @pynting script here: joplin-note/joplin-note.sh at master · pynting/joplin-note · GitHub).
Is there anyone knowledgeable in scripting CLI Joplin using shell scripts that could help me? Basically I need to write a simple script that would batch import every .enex file in a folder, each to a new notebook in the existing Joplin-desktop database. I don't need fancy options or something robust to errors etc., as I would only use it a couple of times to test and finally do the migration of our Evernote data.
If you want to be really super basic and do a bit of dirty work yourself you don't really need the "proper" features of a script. You could just be lazy and create a script that just runs the same command over and over with different file names.
If you put all your enex files into a folder and run ls > files.txt then you should get a text file with all your file names. If you have a text editor (or even joplin itself) that has multi cursor support you can just put the rest of the command for each file in front and behind it.
I've not got any enex files to hand to play with but I think it is just something like joplin import /path/to/file1.enex --format enex --output-format md and all you do is put the joplin import /path/to/ before your list of files and the --format enex --output-format md bit after it so you end up with a script file that looks like:
Then just run the script file which would be just running ./importscript.sh (or whatever you called it) from the terminal.
To start with you should just try running a few of those commands directly in the terminal to make sure it works. Essentially all a shell script does is execute the commands as it reads down the file. So a script like that will just execute the command of each line one by one.
You could obviously do it by setting up a loop and iterating through each file in a directory which would be the "proper" way to do it but if you really don't understand any scripting principals at all then this should make sense for you to tweak it as you need as there is no real "logic" that needs to be learnt.
(And before anyone starts reminding me of grep, actual scripting code, other command line tools etc. etc. I know I'm just trying to come up with an idea that doesn't presume any terminal or scripting knowledge and is innately understandable to tweak and maintain).
Thanks a lot @Daeraxa! I was able to make a single-line command work for import, and to generate a shell script for importing all the .enex files.
I still have one problem while testing on a single notebook: I need to import it into the desktop install of Joplin, not the CLI install, as they are distinct. I can launch and browse the desktop install from the CLI using:
joplin --profile ~/.config/joplin-desktop
However, when running the import command in the Terminal, I can't find a way to target the desktop install. Doing
does not target the desktop database, but the CLI one. I want to run my script in the Terminal while targeting the desktop app, any idea how to do that?
OK that's just me being dumb. The profile option has to be put before the import command. This works to import a notebook into the desktop database via CLI:
It is functional but not supported. It is generally discouraged (any issues caused by doing this is not something that would be accepted as a bug etc.) because the system is not designed to have two clients connected to the same database. However in your case it sounds like you aren't using this Joplin instance as a "live" system as such (yet) and are using it as an environment to get data in and check it exported and imported as expected.
The proper way to do it is what @tessus suggests which is to simply omit the profile flag which will allow the terminal app to simply generate its own profile then set that up to sync with a joplin desktop instance either by a local file sync or your webDAV sync.