Select all files matching selected file's extension

This Opus 9 button lets you automatically select all files in the current lister that have the same file extension as the (first) currently selected file.

For example, select a .png file, click the button, and all .png files will be selected.

<?xml version="1.0"?> <button backcol="none" display="both" textcol="none"> <label>Select Extension</label> <tip>Select All Files Matching the Current File Extension</tip> <icon1>#selectwild</icon1> <function type="normal"> <instruction>@nodeselect</instruction> <instruction>@firstfileonly</instruction> <instruction>@nofilenamequoting </instruction> <instruction>Select PATTERN *{f|ext}</instruction> </function> </button>

Update: Since this was posted, Opus gained a special command, Select SIMILAR, which you may find better than this button. See Steje's reply below.

THX

:slight_smile:

It's a really GOOD tool

Is it possible to extend the button so that any say rar files are also selected.
Rar files have extensions .rar and .r01, .r02 etc - any way of selecting these for a specific name?

[quote="prjparry"]Is it possible to extend the button so that any say rar files are also selected.
Rar files have extensions .rar and .r01, .r02 etc - any way of selecting these for a specific name?[/quote]
Then you can use this button which does the opposite to the one Jon posted:

<?xml version="1.0"?> <button backcol="none" display="both" textcol="none"> <label>Select Same Name</label> <tip>Select All Files With the Same Name (Excluding Extension)</tip> <icon1>#selectwild</icon1> <function type="normal"> <instruction>@nodeselect</instruction> <instruction>@firstfileonly</instruction> <instruction>@nofilenamequoting </instruction> <instruction>Select PATTERN "{o|noext}.*"</instruction> </function> </button>
In other words, it selects files with the same names but different extensions.

Thanks Nudel

Is there a slightly more sophiticated approach.

Here's the scenarion.
downloads are rar files i.e. .rar, .r01,.r02 etc.

Steps to undertake are select .rar right click and extract to here using winzip.
This usually extracts a single .avi or .iso file etc dependant upon what I'm doing.

I then want to select all the .rar,.r01 etc files and delete them.

The problem with your xml button is that it will also select the extracted file and thus I have to scroll and deselect before deleting.

Would be great is I could do all with the press of a button or a combination of select rar etract, select all rar files and delete?

Change the .* to .(rar|r*) perhaps? Might still match unwanted things, though.

You know Opus can extract the RAR too?

hi all,
Nudel, your script doesn't work with new name of RAR archive like:
AC60628.part001.rar
AC60628.part002.rar
AC60628.part003.rar
AC60628.part004.rar
...

Can you enhance your script to take the name of files until the first dot and select the others ?

A few comments:

  1. Opus has an 'internal command to do what Jon's first button does:

<?xml version="1.0"?> <button display="both" icon_size="large" label_pos="right"> <label>Select By Extension</label> <tip>Select By Extension</tip> <icon1>#advancedselect</icon1> <function type="normal"> <instruction>Select SIMILAR</instruction> </function> </button>
2) Nudel's opposing follow-up button seems to fall a bit short on flexibility because it does not work with 'multiple' files selected with different filename prefixes. I've long since broken this out into a script (a modified version of which also used to be my method for the extension based selection above until the function was added internally to Opus):

<?xml version="1.0"?> <button display="both" icon_size="large" label_pos="right"> <label>Select By Filename</label> <tip>Select By Filename</tip> <icon1>#advancedselect</icon1> <function type="normal"> <instruction>@runmode hide</instruction> <instruction>/scripts\selbyfn.cmd {f}</instruction> </function> </button>
...where the 'script' is a batch file named selbyfn.cmd that runs the following:

start "" dopusrt.exe /cmd Select %~n1.*

Note: the button above that runs /scripts\selbyfn.cmd {f} is just calling the batch file from a folder alias on my system called /scripts. Modify accordingly to call a similar batch file from a location on your PC.

@y0y0gigi:
Theres no 'one fits all' approach to do what you want to do AND have it work in the otherwise 'regular' way that the button above works, without breaking things out into a larger vbscript or something that can do some string comparisons and such... but if you use the batch method above, you can then change the Opus button or hotkey to run something like:

<?xml version="1.0"?> <button display="both" icon_size="large" label_pos="right"> <label>Select By Filename</label> <tip>Select By Filename</tip> <icon1>#advancedselect</icon1> <function type="normal"> <instruction>@runmode hide</instruction> <instruction>/scripts\selbyfn.cmd {f|noext}</instruction> </function> </button>

All that's different here is that the value passed to the batch file strips out the extension recognized by Opus, so that the batch file then strips out the 'middle' part of the filename and leaves you with the first part of the name prefix...