With yahoo mail i am not sure.
If you have pop3 access to your yahoo account then I do have an old tool i wrote like 14 years go that was a pop3 email deleter that logged into the account and deleted all the emails you told it to. It still works i think and I could give you a copy of it.
Otherwise another way is if you have imap access to your yahoo account. If you do you could user thunderbird and setup imap access to it, then have it download the message headers only instead of the whole message, this will make it a lot faster on grabbing them all, then you can do a select all and delete them that way as well.
Shane