Select SOURCETODEST or SIMILARBASE with partial match

Cameras often provide the option to save pictures both in .jpg and various raw formats. Other programs might generate sidecar files like .xmp.

When culling pictures it's usually the easiest to just browse through the .jpgs, delete them as needed and then use the following buttion to quickly select and delete the other types:

Go CURRENT OPENINDEST
Select *.jpg DESELECTNOMATCH
Select SOURCETODEST=noext DESELECTNOMATCH
Select NONE
Set DEST=toggle
Select INVERT
Select ALLDIRS DESELECT 

Sometimes however I have lists with variants of pictures that have different names:

DSC12135.arw
DSC12135.jpg
DSC12135.xmp
DSC12135 LR.jpg
DSC12135 DxO.jpg

DSC12136.arw
DSC12136.jpg
DSC12136.xmp

When I delete DSC12135.jpg and run the button I will end up with DSC12135.arw and DSC12135.xmp selected. I would need a modified version of Select SOURCETODEST or Select SIMILARBASE that selects the variants or accepts a parameter like left(n).

Filters cannot be based on selections, right?

Browsing the forum I found Command: SelectEx, which doesn't cover my use case directly but from which I might be able to steal a bit and write a script.

Anybody got some other ideas? Links to other posts are welcome, too.

"Coincidentally" SelectEx has an example for this exact use case if I understood your correctly.. o)
You need to select one of the files with the same base name, then run this command (from a button maybe).

  • Select items with same name as the currently selected (looking at the first 8 chars only)
    SelectEx SIMILARMETAJS="return selItem.name.left(8)==item.name.left(8);"

Oh yeah... Thanks! :slight_smile:

Guess instead of writing this post I should have spent more time studying the SelectEX documentation :wink:

Nah, it's ok. The current presentation of the switches, parameters and examples is not very nice to the eyes. I can understand everyone not reading it! o)

Turns out this is quite easy with a bit of scripting (who would have thought? :wink: )

function OnClick(clickData) {
    var cmd = clickData.func.command;
    cmd.Runcommand('Select *.jpg DESELECTNOMATCH');
    for (var eSel = new Enumerator(clickData.func.sourcetab.selected_files); !eSel.atEnd(); eSel.moveNext()) {
        cmd.Runcommand('Select ' + eSel.item().name_stem.substr(0, 8) + '*.*');
    }
    cmd.Runcommand('Select INVERT');
    cmd.Runcommand('Select ALLDIRS DESELECT');
}

Works well so far, albeit a bit slowly. Not a big deal, but makes me wonder if there are ways to speed up things. The original code works almost in an instant.