How to change all fields in all tiddler?

Hi TW experts,

I want to change all fields with a specific name in all Tiddlers by a button.

My example and use case:
Change all fields with name “Department”, of course only if available but in really all Tiddlers, if it contain "Purchasing " to “Supply Chain”.

Thx in advance
Stefan

Just fo fun I thought I’d ask ChatGPT this question and this is what it gave me

<$button>Change Field "x" to "y"
    <$list filter="[all[tiddlers]has[x]]">
        <$action-setfield $tiddler=<<currentTiddler>> x="" y={{!!x}} />
    </$list>
</$button>

Explanation

  1. <$button>: Creates a button that triggers the action when clicked.
  2. <$list>: Finds all tiddlers that contain the field x.
  3. <$action-setfield>:
    • Sets x to an empty value (removes it).
    • Copies the value of x into a new field called y.
  4. <<currentTiddler>>: Ensures the operation runs for each matched tiddler.

When you click the button, it will iterate through all tiddlers with field x, remove that field, and move its value to y.

I’m not sure setting x to empty will remove it - but the rest looks about right and its worth a try
:smiley:

I suggest a few small changes to the solution provided by @Christian_Byron:

<$button>Change Field "x" to "y"
    <$list filter="[all[tiddlers]has:field[x]!has[y]]">
        <$action-setfield y={{!!x}} />
        <$action-deletefield x />
    </$list>
</$button>
  • Using has:field[x] suffix allows the filter to find all tiddlers in which field x exists, even if that field is blank. Adding !has[y] to the filter ensures that if field y already exists, that field is not ovewritten and the tiddler remains unchanged.
  • $action-setfield defaults to currentTiddler when no $tiddler param is provided. Note also that using x="" does NOT remove field x. It simply sets that field value to blank.
  • $action-deletefield deletes field x from the currentTiddler

enjoy,
-e

1 Like

I highly recommend the utility “Commander” by @Mohammad — which makes all such batch operations smooth.

1 Like

Hi @EricShulman,

thank you for your quick response.
I think I explained it not good enough.

I don’t want to exchange the field “x” with field “y”.
I need to change the content of the field if is match.

  1. Filter all tiddlers having field name “Department”
  2. Filter (1.) for content of field Deprtment match “Purchsing”
  3. Save content of field “Department” with new content “Supply Chain”
Department: Purchasing
tags: 
title: Hamburg

will be changed to

Department: Supply Chain
tags: 
title: Hamburg

and no change here, because the content of Department don’t match

Department: Quality
tags: 
title: Hamburg

Sorry for the misunderstanding, hopefully you can help me
Stefan

Hi @Springer,

I would use the Plugin but I am supporting a wiki for end users without any knowledge and interest to use such tools.
My use case is this:
<$edit-text tiddler=<<field_of_field>> field=<<field>> class="pretty100" />
The user can decide to change the new entry all over the wiki not only for this single change easily by a button.

Thank you so far.
Stefan

1 Like

Try this:

<$button>Change "Purchasing" to "Supply Chain"
    <$list filter="[all[tiddlers]Department[Purchasing]]">
        <$action-setfield Department="Supply Chain"} />
    </$list>
</$button>

The filter uses “Department[Purchasing]” to select only those tiddlers for which the “Department” field has a value of “Purchasing”. This syntax is a short form of field:Department[Purchasing]. See field Operator which says:

enjoy,
-e

1 Like