There is a local train which travels once daily from Badajoz to Entroncamento, which I’m pretty sure is still running. There’s also a local train linking Vigo and Porto, but I’m less sure about that one. Flixbus or similar would probably be easier and faster, but less exciting. In 2nd class this journey should be about €18 in reservation fees.
Timings from Barcelona are as follows:
Barcelona Sants 07:40-10:10 Madrid Atocha (R)
Madrid Atocha 10:35-11:48 Puertollano (R)
Puertollano 12:00-16:05 Badajoz (R)
Badajoz 16:24-18:14 Entroncamento
Entroncamento 18:44-20:12 Lisboa Oriente
*Renfe are not always very dependable for listing their train times in a timely manner. The timings I’ve just listed are for an arbitrarily chosen Monday later this month, as some trains don’t seem to be listed for August yet. As such I can’t promise this will work on the day stated, but hopefully!..