Conditional cover import

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?

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.

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 :wink:

%_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.

Thank you for your ideas, MotleyG :wink: and ohrenkino :slightly_smiling_face:

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.

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

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

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.

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

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.

1 Like

WOW, that's new to me. :+1::+1:

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.

2 Likes

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

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.

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?

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.

1 Like

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

Excellent!