Tag split files

Hi all,
I’m wondering if anyone could help a scripting neophyte. I’ve been using the “Split at Delimiter” action that nahumck pulled together to process some reading notes before sending them as individual text files over to DEVONThink. One thing that would make this process easier would be the ability to tag these files to arrive in a particular workspace for a quick bulk action. (At times there are many many split files). However, I’m not quite sure how to tag the produced split files. Can anyone point me in the right direction? Perhaps an action that already does something similar?

I assume you are using this split action. If so, you can just add a single line to assign the tag you want…like:

// Split at specified delimiter

var delim = “|”;

var text = draft.content;
var chunks = text.split(delim);
for (var chunk of chunks) {
  var d = Draft.create();
  d.content = chunk;
  d.addTag("MY-TAG"); // NEW LINE!

Naturally, you would need to change "MY-TAG" to the value you want for the tag (still in quotes).

Great! That did the trick. Thanks.

If you want to get fancy, you could add this to the end to create and load a temporary workspace displaying those split drafts:

let ws = Workspace.create();
ws.name = "Processing";
ws.tagFilter = "MY-TAG"; // again, edit for tag used

I like fancy! Cheers