How to batch promote attributes after importing enex? #9436
Replies: 3 comments 1 reply
-
|
Hi @mengxin523! I'm Dosu and I’m helping the Trilium team. The ENEX importer in Trilium actually does preserve creation and modification dates from Evernote — it extracts them from the If you want to make these dates visible as promoted attributes (or copy other metadata from the note content into attributes), you can write a backend script to do it in batch. Here's a pattern: // Run this as a backend script (Code note with #run=backendStartup or execute via Script Launcher)
const parentNote = api.getNote("YOUR_PARENT_NOTE_ID"); // root of imported notes
const children = parentNote.getSubtree().notes;
for (const note of children) {
// Copy system dates to custom label attributes
note.setLabel("customDateCreated", note.dateCreated);
note.setLabel("customDateModified", note.dateModified);
// Or parse dates from the note content if needed
// const content = note.getContent();
// ... extract dates with regex ...
// note.setLabel("createdDate", extractedDate);
}
api.log(`Updated ${children.length} notes`);Key API methods for batch attribute operations [2]:
One caveat: api.sql.execute(
'UPDATE notes SET dateCreated = ? WHERE noteId = ?',
[newDateValue, note.noteId]
);To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
|
Thank you very much for your reply. I am new to Trilium, could you please tell me where to run these scripts? @dosubot |
Beta Was this translation helpful? Give feedback.
-
|
This might help: https://docs.triliumnotes.org/user-guide/scripts |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe feature
Hi,
I have imported 2,000 notebooks and found that all their attributes are empty. How can I update these attributes in batches? The creation and modification times of each notebook are available on the notebook page itself.
Regards,
Leon
Additional Information
No response
Beta Was this translation helpful? Give feedback.
All reactions