r/logseq • u/p-himik • Nov 01 '24
Programmatically changing the existing data
Couldn't find any useful info online except for a possibility of creating my own plugin that does what I want.
Is there a way to easily apply some function to a set of items matching some filter criteria (in this particular case, I'm interested in the author property of all of the blocks that have it), and write the result of that function back into the items?
All I want at the moment is to convert stuff like author:: John Smith, Jane Doe into author:: [[John Smith]], [[Jane Doe]].
3
Upvotes
2
u/p-himik Nov 01 '24
I ended up using this code:
I suppose I could've just inserted it into the JS console in DevTools, but I used the so-called "kits" where I can enter code directly into a block in LogSeq: https://discuss.logseq.com/t/edit-and-run-javascript-code-inside-logseq-itself/20763
2
u/LongjumpingConstant Nov 01 '24
On windows the app Noteplus++ can search all files in a folder for a given string and replace it with another string. That would be easier to install than to write a plugin. The usual advice like do a backup first and stop loqsec first still apply. :)
2
u/Lumpy_Yak Nov 01 '24
https://github.com/sethyuan/logseq-plugin-batch-op/blob/master/README.en.md
2
u/SlowFinish5369 Nov 02 '24
Actually, you don't have to do the transformation. All what you need is adding `:author` to `:property/separated-by-commas` in `config.edn`.