# Creating new Media filter rules - should I use SuperTool for these?

**URL:** <https://gramps.discourse.group/t/creating-new-media-filter-rules-should-i-use-supertool-for-these/3171>\
**Category:** Help\
**Tags:** supertool-script\
**Created:** [January 16, 2023, 1:04am UTC](https://gramps.discourse.group/t/creating-new-media-filter-rules-should-i-use-supertool-for-these/3171 "2023-01-16T01:04:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeorgeWilmes](https://avatars.discourse-cdn.com/v4/letter/g/c57346/32.png) [@GeorgeWilmes](https://gramps.discourse.group/u/GeorgeWilmes)\
**Post date:** [January 16, 2023, 1:04am UTC](https://gramps.discourse.group/t/creating-new-media-filter-rules-should-i-use-supertool-for-these/3171/1 "2023-01-16T01:04:00Z")

</div>

I’m thinking of creating a set of filter rules, partly because I think they might be useful to me and maybe to others, but also just as a way to learn how to do it.

The rules I have in mind are these:

Media for people matching the \<filter\>  
Media for events matching the \<filter\>  
Media for sources matching the \<filter\>  
Media for citations matching the \<filter\>

and these:

People with media matching the \<filter\>  
Events with media matching the \<filter\>  
Sources with media matching the \<filter\>  
Citations with media matching the \<filter\>

There seem to be some existing filter rules that I can use as starting points. But I wonder, has anyone already created anything similar in SuperTool, that I could learn from or use as a starting point? I have not used it yet but thought this might be a good time to try. I have only just started reading the documentation and thought I should ask before investing more time.

Thanks for any advice.

---

<div class="post-metadata">

**Author:** ![PLegoux](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/plegoux/32/413_2.png) [@PLegoux](https://gramps.discourse.group/u/PLegoux)\
**Post date:** [January 16, 2023, 5:04pm UTC](https://gramps.discourse.group/t/creating-new-media-filter-rules-should-i-use-supertool-for-these/3171/2 "2023-01-16T17:04:55Z")

</div>

> [@GeorgeWilmes](#):
>
> People with media matching the

[I’ve done that filter](https://www.dropbox.com/scl/fo/wt9lz0zrdfe2i1mssw8d4/h?dl=0&rlkey=fl7roy7676u7vrti2bfwvodvo) as a regular filter [but due to some limitations](https://gramps.discourse.group/t/adding-a-match-media-filter-in-persons-filters/968/2), it is not a very clean filter (I have to enter the name of the media filter in a box, it’s impossible to select it directly as for other _match \<filter\>_ filters).

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/d/d764ecb81b9b87e80c077884a15da3ee25344486.png)

If I’d to recreate it now I’ll do that using SuperTool and [its possibility to acces filters in different namespaces](https://github.com/Taapeli/isotammi-addons/blob/master/source/SuperTool/README.md#using-predefined-custom-filters). Something like that which is looking for people with a picture of their first communion comparing their linked medias to results of a media filter that searches for media tagged “First Communion”:

```python
[Gramps SuperTool script file]
version=1

[title]
SuperTool-People - People with media matching filter - Example

[category]
People

[initial_statements]
# https://gramps.discourse.group/t/creating-new-filter-rules-should-i-use-supertool-for-these/3171

my_media_filter = filter("90. Attribut['Tags', {'Individus': 'Communiant'}] - 090p", namespace="Media")
print('======================================')

[statements]
found = False
for linked_media in obj.media_list:
    linked_media_obj = db.get_media_from_handle(linked_media.ref)
    if my_media_filter(linked_media_obj):
        print(name, ': exist - ', linked_media_obj.desc)
        found = True

[filter]
found

[expressions]
name

[scope]
all

[unwind_lists]
False

[commit_changes]
False

[summary_only]
False

```

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/7/716408656b96cf0b6b40b8c9ec1e928ff70dc54a.png)

> [@GeorgeWilmes](#):
>
> Events with media matching the   
> Sources with media matching the   
> Citations with media matching the

These filters could be easily derived from the previous one.
