# Conditional cover import

**URL:** <https://community.mp3tag.de/t/conditional-cover-import/56278>\
**Category:** Support\
**Created:** [February 11, 2022, 5:51pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278 "2022-02-11T17:51:29Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roland](https://community.mp3tag.de/user_avatar/community.mp3tag.de/roland/32/8001_2.png) [@Roland](https://community.mp3tag.de/u/Roland)\
**Post date:** [February 11, 2022, 5:51pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/1 "2022-02-11T17:51:29Z")

</div>

I would like to correct the cover in my songs via script.  
The goal is an embedded cover with 500x500 pixels in each song.  
Every folder has at least the file 01.JPG or FOLDER.JPG or COVER.JPG.

The import is necessary if  
a) there is no image embedded  
b) the embedded image is not square  
c) the dimensions are smaller than 500x500 pixels.

For this, the variables COVERS as well as COVER\_HEIGHT and COVER\_WIDTH must be evaluated and the function COVER\_IMPORT must be applied.  
But so far I had no idea how to formulate this conditionally.

Who can give me a hint?

---

<div class="post-metadata">

**Author:** ![MotleyG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/motleyg/32/440_2.png) [@MotleyG](https://community.mp3tag.de/u/MotleyG)\
**Post date:** [February 11, 2022, 6:05pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/2 "2022-02-11T18:05:44Z")

</div>

> [@Roland](#):
>
> COVER\_HEIGHT and COVER\_WIDTH

You could apply a filter first, checking for %\_covers% MISSING, the **$less(x,y)** function for COVER\_HEIGHT and COVER\_WIDTH to check dimensions less than 500, and **$neql(x,y)** to check that COVER\_HEIGHT and COVER\_WIDTH are equal.

For all remaining files you could then run your script.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [February 11, 2022, 6:09pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/3 "2022-02-11T18:09:06Z")

</div>

I would use a filter.  
You can store the filter expression in a separate text file and comment on it - but I think that the whole thing is more or less intended to deal with historical files. In the future all covers will be perfect 😉

`%_covers% MISSING OR (%_cover_height% LESS 500 AND %_cover_width% LESS 500) OR "$if($neql(%_cover_height%,%_cover_width%),1,0)" IS 1`

... and then apply the import action.

---

<div class="post-metadata">

**Author:** ![Roland](https://community.mp3tag.de/user_avatar/community.mp3tag.de/roland/32/8001_2.png) [@Roland](https://community.mp3tag.de/u/Roland)\
**Post date:** [February 11, 2022, 6:15pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/4 "2022-02-11T18:15:39Z")

</div>

Thank you for your ideas, MotleyG 😉 and ohrenkino 🙂

The filter method will surely work, but as I need this procedure 3 to 4 times a day,  
I don't want to recode the filter so often.  
The filter definition should be saved within the MP3TAG environment.  
I am investigating how to do this via hotkey or similar.

---

<div class="post-metadata">

**Author:** ![MotleyG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/motleyg/32/440_2.png) [@MotleyG](https://community.mp3tag.de/u/MotleyG)\
**Post date:** [February 11, 2022, 6:17pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/5 "2022-02-11T18:17:11Z")

</div>

> [@Roland](#):
>
> I don't want to recode the filter so often.

It will stay in the filter list, so you can repeat as necessary.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [February 11, 2022, 6:19pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/6 "2022-02-11T18:19:26Z")

</div>

> [@Roland](#):
>
> The filter definition should be saved within the MP3TAG environment

It gets saved in the filter history dropdown list.  
If you really have to do that action that often

> [@Roland](#):
>
> 3 to 4 times a day

I am pretty sure that the filter will be fairly far up in the history.  
Using a filter also speeds up the process if you have to treat many files as only the ones where it matters get treated and not all the loaded (and selected) ones.

---

<div class="post-metadata">

**Author:** ![Roland](https://community.mp3tag.de/user_avatar/community.mp3tag.de/roland/32/8001_2.png) [@Roland](https://community.mp3tag.de/u/Roland)\
**Post date:** [February 11, 2022, 6:19pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/7 "2022-02-11T18:19:51Z")

</div>

Okay, there are around hundred filter expressions in the history.  
How do I get rid of the unnecessary ones?

---

<div class="post-metadata">

**Author:** ![MotleyG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/motleyg/32/440_2.png) [@MotleyG](https://community.mp3tag.de/u/MotleyG)\
**Post date:** [February 11, 2022, 6:24pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/8 "2022-02-11T18:24:36Z")

</div>

> [@ohrenkino](#):
>
> %\_covers% MISSING OR (%\_cover\_height% LESS 500 AND %\_cover\_width% LESS 500) OR "$if($neql(%\_cover\_height%,%\_cover\_width%),1,0)" IS 1

With the filter list open, scroll up/down with the arrow keys. When the one you want to get rid of is highlighted Shift-Delete.

---

<div class="post-metadata">

**Author:** ![Roland](https://community.mp3tag.de/user_avatar/community.mp3tag.de/roland/32/8001_2.png) [@Roland](https://community.mp3tag.de/u/Roland)\
**Post date:** [February 11, 2022, 6:25pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/9 "2022-02-11T18:25:48Z")

</div>

WOW, that's new to me. 👍👍

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [February 11, 2022, 6:26pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/10 "2022-02-11T18:26:55Z")

</div>

You also find functions to handle the filter list when you click on the right-arrow-button next to the list.  
Perhaps you want to clear all entries (first). There is a function for that.

---

<div class="post-metadata">

**Author:** ![Roland](https://community.mp3tag.de/user_avatar/community.mp3tag.de/roland/32/8001_2.png) [@Roland](https://community.mp3tag.de/u/Roland)\
**Post date:** [February 11, 2022, 6:29pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/11 "2022-02-11T18:29:26Z")

</div>

Thank you.  
How can I select a few of the expressions for deletion?

---

<div class="post-metadata">

**Author:** ![MotleyG](https://community.mp3tag.de/user_avatar/community.mp3tag.de/motleyg/32/440_2.png) [@MotleyG](https://community.mp3tag.de/u/MotleyG)\
**Post date:** [February 11, 2022, 6:33pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/12 "2022-02-11T18:33:05Z")

</div>

I'm afraid it is either one at a time, or all. I don't think there is a multi-select option on the lists.

---

<div class="post-metadata">

**Author:** ![Roland](https://community.mp3tag.de/user_avatar/community.mp3tag.de/roland/32/8001_2.png) [@Roland](https://community.mp3tag.de/u/Roland)\
**Post date:** [February 11, 2022, 6:33pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/13 "2022-02-11T18:33:56Z")

</div>

This will definetely speed up processing.  
How to avoid more than one cover per song if there are 2 or more pics in these folders?

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [February 11, 2022, 6:35pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/14 "2022-02-11T18:35:41Z")

</div>

I think the action to import has an option to either keep existing covers or not.  
So if in doubt, I would say: the last imported cover wins.  
It would be up to you to keep the covers on offer up to mark.

---

<div class="post-metadata">

**Author:** ![Roland](https://community.mp3tag.de/user_avatar/community.mp3tag.de/roland/32/8001_2.png) [@Roland](https://community.mp3tag.de/u/Roland)\
**Post date:** [February 11, 2022, 6:37pm UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/15 "2022-02-11T18:37:38Z")

</div>

YEP!  
This will lead to just one pic per song.  
It just needs a reversed load and the best wins.

Excellent!

---

<div class="post-metadata">

**Author:** ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)\
**Post date:** [March 1, 2025, 7:45am UTC](https://community.mp3tag.de/t/conditional-cover-import/56278/16 "2025-03-01T07:45:31Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
