How to create a button to bulk delete fields that match a certain criteria from tiddlers

How to create a button to bulk delete fields that match a certain criteria from tiddlers. Below given is the code which I tried, but this delete only one field at a time. I want to delete all those fields which meets the criteria

\function tbl-fieldnames() 
[<currentTiddler>fields[]prefix[tbl-]enlist-input[]]
\end

\procedure delete-tbl-fields()
<$action-deletefield $field=<<tbl-fieldnames>> $timestamp="no"/>
\end

<$button actions=<<delete-tbl-fields>>>
{{$:/core/images/delete-button}}
</$button>

Two changes:

  • You don’t need a \function to define the filter, and that filter does not need enlist-input[] because the fields[] operator already produces separate list items for each field name.

  • The $action-deletefield widget in delete-tbl-fields() needs to be invoked separately for each field you want to delete, like this:

\procedure delete-tbl-fields()
<$list filter="[<currentTiddler>fields[]prefix[tbl-]]" variable=thisfield>
<$action-deletefield $field=<<thisfield>> $timestamp="no"/>
</$list>
\end

-e

2 Likes

Thank you @EricShulman
It works