Search duplicate caption-fields

113 views
Skip to first unread message

magev958

unread,
Feb 8, 2018, 12:17:28 PM2/8/18
to TiddlyWiki
Most of my tiddlers have a uuid-title and a caption-field. With the collection of tiddler growing I have come across a couple of tiddler with same caption. I would likt to find all duplicates but don't know how
/Magnus

BurningTreeC

unread,
Feb 8, 2018, 1:18:51 PM2/8/18
to TiddlyWiki
hello Magnus,

this could do what you need:

\define compareCaptions()
<$list filter="[[$(firstTidCaption)$]regexp[^$(thisTidCaption)$$]]">

$(firstTiddler)$ and $(thisTiddler)$ have the same caption
<$button message="tm-edit-tiddler" param="""$(thisTiddler)$""">edit $(thisTiddler)$</$button>

</$list>
\end
\define compareTiddlers()
<$list filter="[all[tiddlers]!is[current]has[caption]]">
<$set name="thisTiddler" value=<<currentTiddler>>>
<$list filter="[<thisTiddler>get[caption]]" variable="thisTidCaption">
<<compareCaptions>>
</$list>
</$set>
</$list>
\end
<$list filter="[all[tiddlers]has[caption]]">
<$set name="firstTiddler" value=<<currentTiddler>>>
<$list filter="[<firstTiddler>get[caption]]" variable="firstTidCaption">
<<compareTiddlers>>
</$list>
</$set>
</$list>

Simon

Mark S.

unread,
Feb 8, 2018, 1:22:09 PM2/8/18
to TiddlyWiki
Using only tools available in the core, this works:

<$list filter="[all[tiddlers]has[caption2]each[caption2]get[caption2]sort[caption2]]" variable="capt">
<$list filter="[field:caption2
<capt>count[]prefix[2]suffix[2]] [field:caption2<capt>count[]prefix[3]suffix[3]]" >
Caption: <
<capt>> used in<br/>
<$list filter="[field:caption2
<capt>]">
<
<currentTiddler>><br/>
</$list>
<br/>
</$list>
</$list>

You will want to change "caption2" to "caption" (I needed a smaller data set for testing).
This checks for duplicates of 2 or 3. You can repeat the run for 4, 5 ... etc. However many duplicate captions you think you might have. The problem is that there are no number-manipulating functions in the core. Also, there is no equality filter in the core, so I'm using prefix/suffix which breaks down for higher numbers  with the same number on back and front (e.g. 22)

Good luck
-- Mark

TonyM

unread,
Feb 9, 2018, 10:10:46 AM2/9/18
to TiddlyWiki
Why not have a list of all captions wrapping a list of all Tiddlers that have the same caption. Most may have one tiddler with each caption but you can make it obviouse for captions who have more than one toddler.

Has[caption]

List all Tiddlers with each caption.

Tony

ste...@gmail.com

unread,
Feb 10, 2018, 4:40:52 PM2/10/18
to TiddlyWiki
Hi Magnus,


On Thursday, February 8, 2018 at 6:17:28 PM UTC+1, magev958 wrote:
Most of my tiddlers have a uuid-title and a caption-field. With the collection of tiddler growing I have come across a couple of tiddler with same caption. I would likt to find all duplicates but don't know how

I had success with the following code (seems to list all duplicates of two or more, no matter how many):

<$list filter="[each[caption]get[caption]]" variable="capt">
<$list filter="[field:caption
<capt>rest[1]get[caption]]" variable="capt2">

!!! Caption "<
<capt2>>":
<ul>
<$list filter="[field:caption
<capt2>]">
<li><$link>{{!!title}}</$link></li>
</$list>
</ul>
</$list>
</$list>

Cheers,

Stef

ste...@gmail.com

unread,
Feb 10, 2018, 4:50:06 PM2/10/18
to TiddlyWiki
Just noticed that my code above had a small bug - when one particular caption appeared more than twice, the caption was listed multiple times. I've fixed it here: 

<$list filter="[each[caption]get[caption]]" variable="capt">
<$list filter="[field:caption<capt>rest[1]limit[1]get[caption]]" variable="capt2">


!!! Caption "<
<capt2>>":
<ul>
<$list filter="[field:caption
<capt2>]">
<li><$link>{{!!title}}</$link></li>
</$list>
</ul>
</$list>
</$list>

Cheers,

Stef

magev958

unread,
Feb 11, 2018, 10:57:52 AM2/11/18
to TiddlyWiki
Thanks I got it to work as expected :)
I haven't had time until yesterday today

@BurningTree I tried your code to, but it made my browser to hang. I guess it was to complex :D

Thanks for your help
/Magnus

HansWobbe

unread,
Feb 11, 2018, 11:25:50 AM2/11/18
to TiddlyWiki

@Stef:  Elegantly simple.  It helped me clean up a bad practice.  Thanks for sharing. ~ Hans
Reply all
Reply to author
Forward
0 new messages