In general I recommend to use Apple's shortcuts app for such things.
However I'm currently finishing some basic loops and conditionals which will allow to do this directly in BTT. Currently planned for BTT 4.200 end of August.
You could already do it right now with some scripting.