Easiest way to batch create tiddlers that only differ on their titles?

My use case

I’m keeping a reading list. Relevant tiddlers are tagged as:

  • authors
  • books
    • some of which also tagged as collection
    • some of which also tagged as short stories (Not the cleanest approach ontologically, but it keeps my templates & filters simple). Short stories have a collection field with the title of the book they belong to.

I’d like to be able to provide a list of titles and a means to define fields to be applied to all of them (I guess by pressing a button?). Something like this, with two plain text input boxes:

Titles:

Story A
Story B
Story C

Fields:

tags:short book todo
author:[[Author Name]]
collection:[[Collection Name]]

Pressing the button should create 3 new tiddlers, all having the same 3 tags, same author and collection details.

There are probably more spot-on solutions for you but if the number of tiddlers is not huge, then maybe https://newtids.tiddlyhost.com/ could be of use. Basically, you could use excel to first make two columns with title and text and then just copy paste those columns into the newtids macro, where you add some tags via the macro UI. Then you need to manually click every title to have its tiddler created (this is why it is not appropriate for a huge number of tids).

1 Like

Thanks for the suggestion, I’ll have a look.

Thinking more about it, the fields don’t need (or even should) to be in free form. My (current) needs are quite specific, maybe I should settle with 3 single-line input boxes instead of a multi line text area.

It would keeps things simpler, one for each of tags, author and collection fields and directly feeding their values into a $action-setfield widget. No fancy parsing needed.

Then wrap that inside some form of iteration that splits the Titles text area into lines and feeds an $action-createtiddler.

Now all I need is the syntactic glue to piece that monster together :zombie:

I would definitely look at Commander, which is designed for tasks similar to this.

One question: Are you expecting to add fields to existing tiddlers, or are you creating them with this action and these fields? If it’s the former, would a slightly more sophisticated UI be an improvement: a search field that lets you select the title based on a few typed characters?

2 Likes

I don’t know how to do it in batch mode, but the TiddlyWiki web interface has the option to clone a tiddler. If you have lots of tiddlers with exact;y same fields (except the title), why not creating just one, then clone it and rename the clones?

I think that your use case is a very specific one that you need repeatedly, but to use a more multi-purpose tool, here’s how you could accomplish your example using Wrangler: Easy querying and modification of your wiki

Generate 3 tiddlers with names as you described and add your tags. Enter those fields and click the “update” button.
{2ACA7499-6DCF-4E29-B846-2B2718D78C3D}

Then you’d fill each of the other cells if you like. In the fields block, just make the field you’re editing last (similarly click the update button here, then repeat for “collection”:
{014CA64E-5C89-4A67-AE8A-6E917AF83B53}

I’m working on the documentation right now, it’s a pretty cryptic tool, so I’d also recommend checking out TiddlyCommander from Kookma or EditTable from TiddlyTools as well which do similar things with more hand holding.

1 Like

Wow, so many interesting replies, thank you everyone :slight_smile:

I know of TiddlyCommander and use it regularly, I’ve also heard of Wrangler but I haven’t yet needed it. Both great tools but they’re not really what I’m after (though I could get by with using them). I even thought about using a spreadsheet and feeding it into the XLSX Utils plugin but that’s exponentially more labor intensive.

Creating dummy titles in TC/Wrangler and then renaming them by hand defeats the purpose of what I’m after: “Here are X lines of text, create a tiddler for each of them using the current line as the title”. I guess the tags/fields can be edited afterwards in TC/Wrangler.

Here’s my exact use case. I’m into reading short stories, and occasionally I stumble upon articles like “10 short stories by Author from their new Short Story Collection”. I want to keep a note of those 10 stories for future reference.

Right now I create 10 tiddlers by hand, copy & pasting the title of each one as I create them. Then I use TiddlyCommander to batch edit the author & collection fields and assign their tags. That’s 2 separate, manual operations in TC in addition to all the copy & pasting of titles.

We can do this manually, by creating edit fields for the list of titles and the field/value combinations, and then writing something like this:

<$button>Make Tiddlers
  <$let fieldvalues={{{ [<currentTiddler>get[fieldvalues]] }}}>
    <$list filter="[{!!titles}split<newline>trim[]] :filter[!match[]] +[reverse[]]">
      <$action-createtiddler $basetitle=<<currentTiddler>> >
        <$list filter="[<fieldvalues>split<newline>trim[]] :filter[!match[]]" variable="fieldvalue">
          <$let 
             name={{{ [<fieldvalue>split[:]first[]trim[]] }}}
             value={{{ [<fieldvalue>split[:]last[]trim[]] }}}
          >
            <$action-setfield $tiddler=<<createTiddler-title>> $field=<<name>> $value=<<value>> />
          </$let>
        </$list>
        <$action-navigate $to=<<createTiddler-title>>/>
      </$action-createtiddler>
    </$list>
  </$let>
</$button>

On clicking the button, we save the field fieldvalues (just because currentTiddler will be changing, and it’s easier to get now.), split the titles field on a newline (defined above with \function newline() [charcode[10]]), trim each of the results, and filter out any empty lines. I also reverse this list so that when they’re added to the story river below, they’ll be shown in the order defined in your list.

For each of these titles we create a tiddler with that value as basetitle (meaning that if we are trying to create My Tiddler and that already exists, it will us My Tiddler 1 or My Tiddler 2, etc.) We use our fieldvalue variable, split it on a newline, again trimming and removing empties. Then for each one, we split on the colon, trimming the results, to give us a name and value, and we use these to set a field value of the current tiddler. Then we navigate to the tiddler. (If you don’t want this, you can just delete the $action-navigate line; and if so, you might as well remove the reverse above.)

The createTiddler-title variable, if it’s not familiar, is set by the $action-createtiddler widget.

This is a minimally styled tiddler demonstrating the idea: Batch Create.json (1.6 KB) You can download it and drag the resulting file onto any wiki to test. (I have some sample values in there. You can remove them with the Clear button.) It looks like this:

After clicking:

2 Likes

Nice!

If you like dynamic tables, amplify the usefulness by having an editable dynamic table appear, at bottom, AFTER you’ve used this button… with rows for your titles and columns for your fields, AND an interface for adding new fields on the fly:

2 Likes

Very nice!

I sent too soon. I meant to suggest that the OP might want to replace my navigation step with something like that, but I was thinking only of a <<list-links>> widget. This table is much better.

I’ve tinkered a bit more, but other tasks call.

Just a bookmark: it would be ideal if my table coped better with the fact that if the specified titles already exist, your button does make new tiddlers that include a numeric suffix in the title (as TW always does, of course). This sudden proliferation can happen even if someone just accidentally clicks the button twice.

Number-sequenced tiddler-title variants don’t show in my table, and it’s not obvious how we’d track exactly which tiddlers had been created with your button…, unless the button also encodes some “watermark” feature to distinguish proper members of its batch from other tiddlers matching a title # pattern…

Actually, I wonder whether the tm-new-tiddler action could somehow do something to flag the difference between when it succeeds with the passed title “as is” vs when it resorts to making a sequence-variant title… This seems adjacent to an error-logging task. :thinking:

You can also use PowerSearch by @EricShulman. Open TiddlyTools and navigate to $:/AdvancedSearch.
It allows you to filter a list of tiddlers, clone entries, and even make fine-grained adjustments to titles.

Pehaps an alternative would be to keep a list in the $:/temp namespace of the tiddlers created this session.

<$action-listops $tiddler="$:/temp/batch-created" $field="text" $subfilter="[<createTiddler-title>]"/> 

with whatever sort of display you like, perhaps a simple:

<details open><summary>Created here (this session only)</summary>
  <<list-links filter:"[enlist{$:/temp/batch-created}sortan[]]"  emptyMessage:"None so far">>
</details>

or we could clearly extend your dynamic table to use that list.

While I don’t think we’d want that in core, as any such flag could be problematic, for our specific case, we could do something like

        <% if [<createTiddler-title>!match<currentTiddler>] %>
          <$action-listops $tiddler=<<createTiddler-title>> $tags="Renumbered"/> 
        <% endif %>  

(right around where I do the navigation.)

This version includes both of these ideas:

BatchCreate_2.json (2.1 KB)


But for the OP, perhaps an easier experience would be to delete the titles and fieldvalues fields after processing, so an accidental second “Create” would not do anything.

There’s an even easier way if anyone is interested…

No teasing, now!

:grinning_face_with_smiling_eyes::grinning_face_with_smiling_eyes::grinning_face_with_smiling_eyes:

This is exactly what I had in mind, thank you very, very much. I also appreciate the thorough explanation and step by step description, I’m sure I’ll re-use bits and pieces of it elsewhere.

@Springer I ended up using your tweak, I’m a big fan of @Mohammad’s Dynamic Tables and their use here fit my needs like a glove. The only change I added was a trim[] to the Dynamic Table’s filter and a tbl-expand to adjust the tiddlers in-place.

Once again, thank you to everyone that brainstormed with me in this :slight_smile:

1 Like