On Monday, 22 September 2025 15:45:17 British Summer Time Peter Humphrey wrote: > Greetings, > > I noticed today that my mail filters weren't working right, so I had a look > at them. I found 127 in place of the 30-odd there should be. Most of those > are duplicates of good ones, and so I'm left with a dilemma: do I delete > the lot and start from scratch; do I try to find an old backup with a good > exported list of filters; or do I try to remove the rogues by hand? All > those options are heavily error-prone. > > By habit, I try to remember to export the filters to a text file whenever I > make a change, so they should all be present in the text file if I haven't > missed any. > > Recovery from backup sounds easiest, and indeed I have weekly, monthly and > yearly backups going back over some years. The complication is that the > exported list of filters will be buried in a tar file of my /home partition, > so I'll need to 'tar tf' each file and grep for KMailFilters.txt. Easiest > perhaps, but I may lose the will to live while waiting. My own ~/ directory > is 6GB today; half of /home. > > Has anyone an idea? That nice Mr Google only casts gloom around. In my day, > I might have written code to extract each filter into a file of its own, > but that was 40-odd years ago. And the ToolbarName, the most easily > recognised property of each filter, is somewhere in the middle of a block > of 30-50 lines.
I'll leave the awk scripting for dedup to more capable contributors, but if this is an one-off problem it may be easier and quicker to run 'tar -tvf somearchive.tgz | grep KMailFilters.txt' starting with the most recent backup archives. At some point you'll come across an archive which has a smaller KMailFilters.txt file size than the current file. Then you can extract and diff that file with your current version. My suggestion falls apart if the duplication of filters was not caused by a single event, but has crept in progressively over the years. In this case a deduplication script will be a better way to approach this.
signature.asc
Description: This is a digitally signed message part.

