Page 1 of 1

Selection of every __th file in a folder?

PostPosted: Wed Jan 25, 2017 3:43 pm
by Thoughtfree
Hello from a new member. Thanks to the brilliant creators of this great utility.

My question: how do I select every other file, or every fifth file, or similar?

I'd like to keep every fifth image in a folder containing thousands of bmps, and delete the rest. (I haven't dug too deep into BRU yet, and perhaps the answer is already in the help area.)

Anyway, thanks if anyone can answer this question.

Re: Selection of every __th file in a folder?

PostPosted: Thu Jan 26, 2017 7:19 pm
by JMM
Actually BRU is not designed for that, but you can use it for that purpose.

A good idea is using the Numbering (10) criteria. Once you have selected all the files from which you want to select only the fifth file, in Numbering select mode: prefix; start: 0; incr.: 2; pad: 2; sep: a space (or any other single character you want; and break: 1.

What this does is renaming every file adding a prefix like 00, 02, 04, etc. but the numbering scheme is broken and reset when the first character changes, that's after the fifth file when it's being renamed to 10, and starts from 0 again. So now every fifth file has 08 as a prefix, thus making easy selecting and deleting everything else. After doing it, select the files again and remove the first 3 characters '08 ' using Remove (5) to revert to the original filenames. Remember to reset/disable Numbering after you apply it! Uncountable times I've applied the same criteria again without remembering to disable it; but BRU has Ctrl+Z to revert the last changes.

This all would be easier if break would work more straightforward, like 'break after the count has reached XXX', but with some practice and changes on increment and pad you should be able to make it work for other Nth files, and with some imagination, devise schemes for any other selection criteria.

Hope this helps.

Re: Selection of every __th file in a folder?

PostPosted: Sun Jan 29, 2017 12:18 am
by JMM
Well I found a simpler way to do any nth file, using a similar method as the one I described above.

Imagine we want to select every 7th file. We set the numbering to start at 3 (10-7 = 3), with pad at 2 and breaking at 1. That way the first file prefix will be 03, second 04... Seventh will be 09, and the eighth would be 10, but since the first char changes, it breaks and it's renamed to 03. So all files beginning with 09 will be the seventh file.

With the 15th file? Numbering starts at 85 (100-85 = 15), pad will be 3 this time, and breaking again at 1. First file will start with 085, second with 086... The fifteenth will be 099, and the sixteenth would be 100, but again the first char changes, it breaks and will have prefix of 085. In this case, the files beginning with 099 will be the 15th file.

As I said, it's a matter of imagination. BRU is a very powerful and flexible tool. Understanding what each criteria does will unleash all the possibilities.

Re: Selection of every __th file in a folder?

PostPosted: Mon Jan 30, 2017 7:06 pm
by Thoughtfree
Thanks for thinking this through - very kind of you, I never could have done it. I will try this method.