If you were to catch a train from a place in north Wales to Holyhead for the ferry to Dublin, you should be able to pre-purchase a combined ticket from this website - but check the costs of doing it separately first.https://www.arrivatrainswales.co.uk/SailRail/RouteMap/
Now look at this map:> http://www.projectmapping.co.uk/Reviews/Resources/ATW%20Route%20Map%20-%20Dec%202013.pdf
When you go from Bath to SE Wales, you will be on a train that goes via Bristol and then through the Severn Tunnel under the estuary.
This train will be going to Cardiff (1 hour from Bath) - the Welsh capital - which in itself is worth a visit. www.visitcardiff.com
/http://cadw.gov.wales/daysout/caerphilly-castle/?lang=en (which is a 20 minute train ride N of Cardiff).
Anyway, you are heading for north Wales so you must change trains at Newport. From here, direct trains will take you N on a line that more or less follows the Wales/ England border. This route is quite scenic but you will not be able to open the windows on any train as they are air conditioned and tinted - making photography difficult. On this route, Ludlow and Shrewsbury are worth a look but you are not allowed to hop off the train and then catch a later one unless you split the tickets. The Holyhead bound trains call at the English border city of Chester. You may well wish to consider spending 1 night here before proceeding along the north coast the next day.
You may wish to consider staying in Conwy - which has a castle & is near to the seaside town of Llandudno as well as Bodnant Gardens. (You must inform staff on the train that you wish to get off at Conwy - do this after Chester). BTH > CNW would take 4 hours 42 minutes & cost £31 if booked in advance. (Price rises nearer date according to demand). BTH > CTR (Chester) would take 3 hours 45 minutes & cost £27 if booked in advance. However, when you put in for this journey, you must use the VIA drop down menu and insert AGV or most trains will be offered via a more expensive route via Birmingham. See www.nationalrail.co.uk
Now go back to the map. Can you see a line that goes W from Shrewsbury? This is a very scenic route that goes through to the west coast. The seaside town of Aberdovey is attractive. The line then goes N up the coast via Barmouth. Minffordd is the station for the village of Portmeirion whilst nearby Porthmadog is a good centre for getting out and about in this area. You could consider staying in Porthmadog as it has 2 narrow gauge steam railways that would take you on scenic routes - see www.festrail.co.uk
BTH > PTM (Porthmadog would take 6 hours 25 minutes & cost £31 if booked ahead. Turn up & pay on the day would be £53.80).
If you were to stay in Caernarfon, you would need to take the train from Bath to Bangor and then bus for the short hop to Caernarfon.
If you can’t find a suitable B&B in Porthmadog - try the Travelodge. For Caernarfon - try the Premier Inn.
If you were staying in Porthmadog & wanted to get to Holyhead for the ferry, you could take the Welsh Highland Railway 1 way to Caernarfon - then bus to Bangor & train to Holyhead. OR - bus from Porthmadog to Bangor & then train to Holyhead.
Google places mentioned for more info.