I have spent 4-1/2 months in Spain (2 trips) since 2016, and I have done all my traveling by public transportation. Sometimes there are trade-offs in terms of speed, and there are super-small places that are impossible to reach by public transportation. But will a 6-week itinerary necessarily include any of those places? Possibly not. Or, worst case, most likely just a few of them. In all likelihood your ultimate itinerary will be something that can be accomplished primarily by train and the occasional bus. Then you can add on a short-term car-rental or two to deal with otherwise-thorny segments of your trip.
You don't want a car for the big cities, obviously ($$$ parking fees, and the car will just sit). There's extremely fast rail service (much speedier than a car) running from Barcelona through Madrid to Cordoba and Seville as well as from Barcelona to Girona and Figueres (on the line that heads to Paris). There's fast-enough service from Cordoba to Malaga, Cadiz and Granada. Madrid to Toledo (dead-end spur line) is very rapid, as is Madrid-Valencia. Beyond those segments, a car might be about as fast as a train or train/bus combination, but in many cases it will not be any faster.
Areas where a car is very desirable are the small white villages in Andalucía (if you want to see more than one or two of them) and the Pyrenees. A car will often make trips across northern Spain more efficient but is unnecessary if you just want to travel to San Sebastian and Bilbao from Barcelona or Madrid.
Do you have any thoughts yet on where you want to go?
You can take a quick look at train travel times on the Deutsche Bahn or Renfe websites. Unfortunately, the Renfe database doesn't seem to recognize the existence of such a thing as a connection. Frequently one needs to change trains in Madrid, and Renfe will simply not display those routes. If in doubt, break a trip up into segments into Madrid and out of Madrid. You need to look elsewhere on the Renfe website for some local/commuter trains, but it's quite possible your itinerary will not involve any of those.
You can use the website Rome2Rio.com for high-level information about whether rail service and/or bus service is available to a particular town and where you might need to change trains or buses. Unfortunately, the more specific information displayed there (fares, travel times, frequencies) is wildly unreliable. Rather than trusting it, you really must drill down on Rome2Rio to find the name of the bus company providing the service (or check Renfe for trains). Usually you'll eventually find a link to the appropriate website. Otherwise, just Google something like bus Bilbao to Oviedo.