There is no direct train from Barcelona to Castelo Branco.
You would need to take a train from Barcelona to Madrid and then a train or bus from Madrid to Lisbon.
Altenatively, vueling.com fly from Barcelona to Lisbon.
There is a train from Madrid to Badajoz but you would have difficulty getting from Badajoz to Castelo Branco.
If you are going to the Boom festival, the organisers do offer buses from Madrid and Lisbon Airports.
See: http://bit.ly/cHU6d7
Also see my recent comments here: http://bit.ly/ayPd2E and http://bit.ly/9aU8gD.
From Lisbon you would need to get a bus from Lisbon Sete Rios Bus Station to Castelo Branco,
For timetable see: http://scr.bi/d72U1m (Page 2 - Scroll Down)
or Train
For timetable see: http://scr.bi/bnFP8W
Hope this helps.