[TW5]is it possible to remove all empty fields from tiddlers?

239 views
Skip to first unread message

Siniy-Kit

unread,
Mar 22, 2017, 3:26:34 AM3/22/17
to TiddlyWiki
Hi! I want to make button to delete fields from ALL tiddlers, if they are empty. Is it possible?

Jed Carty

unread,
Mar 22, 2017, 7:36:13 AM3/22/17
to TiddlyWiki
Yes, but be very careful with this!! The version that works on all tiddlers may cause unexpected problems if you have a large wiki do to rendering issues.


This will list all the fields in the current tiddler that are empty, it works well:


<$list filter='[<currentTiddler>fields[]]' variable=fieldName>
<$list filter='[
<currentTiddler>!has<fieldName>]'>
<
<fieldName>>
</$list>
</$list>


This will remove all empty fields from the current tiddler, it works:

<$button>doo EET!!
<$list filter='[
<currentTiddler>fields[]]' variable=fieldName>
<$list filter='[
<currentTiddler>!has<fieldName>]'>
<$action-deletefield $field=<
<fieldName>>/>
</$list>
</$list>
</$button>


This will remove all the empty fields in all tiddlers, if it ever renders:

<$button>doo EET glow BALL eye!!
<$list filter='[!is[system]'>
<$list filter='[
<currentTiddler>fields[]]' variable=fieldName>
<$list filter='[
<currentTiddler>!has<fieldName>]'>
<$action-deletefield $field=<
<fieldName>>/>
</$list>
</$list>
</$list>
</$button>

it takes a few seconds to render on tiddlywiki.com, and then a few seconds to actually finish, but it seems to work. When I used '[all[]]' as the outer filter instead of '[!is[system]]' it changed some plugin tiddlers so I don't trust that. And I wouldn't trust this much ether unless you have some way to test that it didn't break anything.

@TiddlyTweeter

unread,
Mar 22, 2017, 4:29:40 PM3/22/17
to TiddlyWiki
Ciao Jed & Siniy-Kit

This whole thing with BULK procedures I think is very interesting.

Slightly out of left-field I see TW simply as a structured text file. Using EXTERNAL tools on a non-running TW for operations like that also seems of merit.

Doing what you want is pretty easy through well devised regular expressions from an external app. And likely without the potential issues you have if its running live.

Best wishes
Josiah

Jed Carty

unread,
Mar 22, 2017, 4:55:19 PM3/22/17
to TiddlyWiki
Before turning to an external app, making a simple widget that takes care of this would be a relatively simple task. If I ever get around to putting together the suite of tools I have for myself something like that may be a part of it.

@TiddlyTweeter

unread,
Mar 22, 2017, 5:07:13 PM3/22/17
to TiddlyWiki
Ciao Jed

Its easier if its internal. Familiar terrain. But the truth is that some BULK operations in TW users could benefit from are not yet quite there.

Best wishes
Josiah

Jeremy Ruston

unread,
Mar 22, 2017, 5:17:16 PM3/22/17
to tiddl...@googlegroups.com
Another way to think about things is that TiddlyWiki lets you fairly seamlessly switch between different perspectives/modalities in using the single HTML file configuration:

* As an web app, experienced through the browser
* As a single, opaque file that can be emailed/Dropboxed/Slacked etc. as a blob
* As a plain text file that can be backed up, edited, etc just like any other text file
* As a fancy ZIP file that can contain multiple items
* As a standalone tool to process content elsewhere, for example to generate a static, secondary representation of content for publication/distribution

While the specific capability to perform bulk operations like search and replace is useful, I think the real value is more conceptual: we can switch between different ways of thinking about TiddlyWiki according to the task we face.

Best wishes

Jeremy.


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/3105460f-be6e-420d-ab1e-7dfe9e706103%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

@TiddlyTweeter

unread,
Mar 22, 2017, 6:40:17 PM3/22/17
to TiddlyWiki
Jeremy

It is VERY good to read that from the founder.

One does not need to be guilty of an external approach sometimes. I personally like very much that TW is SO WELL structured. It is extremely easy to externally RegEx over because of that.

Best wishes
Josiah

Siniy-Kit

unread,
Mar 23, 2017, 4:52:59 AM3/23/17
to TiddlyWiki
Thank you Jed, your <$list filter='[!is[system]]'> works good. But I had 14000 tiddlers in my tw5 (61mb weight)
so this macros say "good bye" and only I can do - open TW5 by notepad and use find and replace to delete myfield=""

 

среда, 22 марта 2017 г., 14:36:13 UTC+3 пользователь Jed Carty написал:

David Szego

unread,
Mar 23, 2017, 3:46:33 PM3/23/17
to TiddlyWiki

On Thursday, 23 March 2017 04:52:59 UTC-4, Siniy-Kit wrote:
... open TW5 by notepad and use find and replace to delete myfield=""

Not a bad solution at all, probably took you a whole 30 seconds total.
Reply all
Reply to author
Forward
0 new messages