How to Auto Title notes that were imported?

Imported about 900 notes from Evernote (bye bye)
I have about 1/3 of those notes are "Untitled Note", is there a plugin or procedure that will 'run' and auto title these notes.
I've been doing them manually and it's not a great big deal but just don't wanna waste my time if I don't need to.

THANKS

1 Like

Perhaps the Jarvis plugin can help with this. See this guide on auto-annotations. This is not a complete solution, as it will not annotate 300 notes with 1-click, but each note can be auto-titled with a single click. Could potentially save you some time. You can also use it to add tags, summaries, and links to other notes, among other features. This requires access to an AI model (online or offline), and to allow Jarvis to send the note content to that model.

2 Likes

Why don't these notes have titles? They had titles in Evernote. Did you export the notes to 'enex as markdown'?

Yes, Unknown why

I just did it the long way, just got carried away and found I was done before I thought... it was hundreds tho.

Assuming you still have all those notes in Evernote, I would consider deleting them all from Joplin and redoing the import the proper way. Either you did something wrong, or there is a legit bug that should be raised and fixed.

Either way, I think it's worth figuring this out, instead of wasting time retitling notes.

1 Like

With my Windows desktop copy of Evernote version 10.67.2 running on Windows 11 Home x64 I also have found the same problem. I don't see any option in Evernote's ENEX dialogue to export in Markdown format, the only choices offered are Title (which is ticked but is greyed out), Note creation date, note updated date etc. There's no sign of any Markdown setting. Even though the greyed out Title choice appears to be ticked, the titles don't make it to Joplin version 2.12.19 (running on the same Windows 11 PC).

My mistake - you export as enex, and in Joplin, import enex as markdown:

image

You should submit a bug report. Perhaps Evernote changed something recently with the enex format that screws up import. Many of us on this forum have come from EN, and hundreds of thousands, if not millions, of notes must have been imported from enex files without this missing title issue.

If you can create a notebook in EN with some notes that aren't confidential, export as enex, import into Joplin using enex as markdown, and have missing titles in the imported notes, then you can submit that enex and I'm sure @laurent will be able to figure out the issue.

Well of course the thing to do, which I should have done before, was to examine the ENEX file in a text editor and sure enough the problem is in Evernote's export to ENEX facility. All my ENEX exports have the note titles set to Untitled Note. Maybe this is one of the "improvements" Evernote introduced with version 10. I suspect the legacy version of Evernote got this right. I knew I shouldn't updated to the new version. I wonder if I downgraded back to the Legacy version would my notes still load ok?

1 Like

Yeah, use Legacy. That's what I used to export several thousand notes. I've heard others say they used Legacy instead of v10 for exporting to enex, though I've never heard of this missing titles issue before.

I have exactly the same... AND I did do the exact export and Import that jb261 showed. Like i said i had about 300 out of 900+ notes not carry over the title.

(3 of my folders were under 25 notes, one folder had only 5 notes and all were untitled)

See @JBa6's most recent post - have you looked at your enex files in a text editor? It sounds like the problem is with Evernote. Did you use v10 or Legacy to export notebooks to enex?

We have seen this before, it isn't anything to do with Joplin, if you could look at an affected note in the enex they have the title literally set to "Untitled note" in the title tag. Joplin just honours that verbatim.

2 Likes

I'm very pleased with Joplin so far, and like i said before, I already 'hand' corrected the titles. If there was a lesson to be learned in my export/import experience then I'm not sure I know what it is but it now don't matter.
I say THANKS to all who responded and I'm looking forward to now adding PLUGINS!!!!

Further investigation of my Evernote 10 installation showed that even though all my notes are correctly listed in in Evernote the right order (ie by title) in each of my notebooks and if an individual note is then selected it also has what appears to be the correct title at the top of the note pane if you instead right click on a note's snippet in the central Note List pane and select Note Info from the right click menu the majority of my notes apparently don't really have a title "under the bonnet".

The Evernote export to ENEX is therefore probably working correctly, Evernote for some reason has as far as it's internal workings are concerned lost the note titles in a way that's not visually obvious to the Evernote user.

Fixing this seems to require selecting the displayed Title text ineach note's pane and typing or copying in the required title text and pressing the enter key to fix it. I suspect this problem of Evernote losing the underlying titles was not present in the Legacy version of Evernote, it's a problem that arose with the upgrade to Evernote version 10 which I believe included converting the notes database to a new format.

1 Like

Thanks for digging into this, @JBa6.

Evernote should really fix this, but I guess they don't have much incentive to make their notes truly portable at a time when they are raising prices and many of their users are looking at competing apps.

I wonder if EN v10 users can install EN Legacy and create functional enex files that way? I know those who never left Legacy will have no problems - that's what I used when I moved to Joplin.

As far as I can tell it's impossible to go back to Legacy once you've upgraded to v10 because the local notes database files have been converted to the new regime and are no longer compatible with the Legacy version. I think Evernote did warn that this would be the case when v10 was released.

I had thousands of notes with this problem, I had left them untitled and used Evernote's feature of showing the first lines to distinguish them, but when moving them to Joplin I only get the titles, so I need to edit the titles to reflect the first line.

So I asked Bing for help to craft some python code to fix this problem. After some back and forth we came up with a program that reads every .enex file in its directory and for each note if the title is "Untitled Note" and there is a first line of text that can be used as a replacement, then the title is changed to reflect the first line.

Use this to modify your .enex files before importing them into Joplin.

Note: This program overwrites the files so keep a backup of the originals if you want to keep them.

Note: I had one bug caused when a source-url field contained an '=' character, not sure why, but when I edited the enex file to delete this line it worked fine.

Note: Some of this code could theoretically be simpler but then it encountered errors when opening complex data files, something to do with non-unicode characters encountered in the .enex files. This is the simplest version that worked for all of the .enex files that I had.

Here's the code:

# max chars in title
titleLength = 40

import re
import html
import os
import xml.etree.ElementTree as ET

# define a function that takes a string as an argument and strips all html fields
def strip_html_fields(new_title):
    # use re.sub to replace any html tags with an empty string
    # the pattern is < followed by any characters until >, with the flags re.IGNORECASE and re.DOTALL
    # the replacement is an empty string
    # the string is new_title
    return re.sub("<.*?>", "", new_title, flags=re.IGNORECASE | re.DOTALL)

# Define a function that takes a file name as an argument to process that file
def process_file(file_name):
    print("##################")
    print(file_name)
    # parse input.enex file
    tree = ET.parse(file_name)
    root = tree.getroot()
    
    # Loop through all the notes in the tree
    for note in root.findall("note"):
    
        # Get the title and the content of the note
        title = note.find("title").text
        content = note.find("content").text
    
        # Check if the title is "Untitled Note"
        if title == "Untitled Note":
    
            # Find the first div in the content
            start = content.find("<div>")
            end = content.find("</div>")
    
            # Extract the text between the div tags
            new_title = content[start + 5 : end]
            new_title = strip_html_fields(new_title)
            new_title = new_title[:titleLength]
            new_title = new_title.strip()
            
            if new_title: 
                # Replace the title with the new title
                note.find("title").text = new_title
                print(new_title)
        note.find("content").text = '<![CDATA[' + content + ']]>'
    
    # write the modified tree to output.enex file
    tree.write(file_name)
    
    # open the .enex file in binary mode to convert HTML character codes into text equivalents
    with open(file_name, "rb") as f:
        # read the file content as bytes
        data = f.read()
        # decode the bytes using utf-8 encoding
        text = data.decode("utf-8")
        # unescape the HTML character codes using the html.unescape function
        text = html.unescape(text)
    
    # open the .enex file in binary mode to write the output
    with open(file_name, "wb") as f:
        # encode the text using utf-8 encoding
        data = text.encode("utf-8")
        # write the data to the file using the file object's write method
        f.write(data)

# Get the current directory
current_dir = os.getcwd()

# Loop through all the files in the current directory
for file in os.listdir(current_dir):
    # Check if the file has the .enex extension
    if file.endswith(".enex"):
        # Apply the function to the file name
        process_file(file)

To use this just save this code in a text file called RenameNotes.py
Place the text file in a directory with some .enex files you wish to transform.
Then open a terminal in this directory and type:
python RenameNotes.py
The resulting .enex files should be able to be imported into Joplin with the note titles reflecting the first line of the note.
Remember, make a backup!
Good luck!

4 Likes

Thanks for the program. Just to note that if the chosen title text contains & it will not put the & entity in the title.

Attempting to import such will fail, and maybe crash Joplin, still waiting for it to "finish" after click past the error message.

No, that's not the whole story. I see & in some of the titled-by-Evernote notes, but after running the program, they get converted to & alone. Whereas, the ones that were untitled before, and have & in the first line of text, keep the &

So it seems the program fixes the Untitled Note problem, but replaces it with a new problem for notes that had titles including &