Control a relay

My question is can you replace the switch in this diagram with a spdt relay (or two) and control them using an arduino uno and the adafruit motor shield:

And if it is possible, how is it done?

Yes you should be able to do that. I didn't fully see what that switch was doing, but in general you can replace a switch with a relay. If you need to have a 3PDT relay you could certainly find one on Digikey, Mouser, etc. You could also use 3 SPDT relays, but you would want to make sure they all switch together.

Depending on the relay, you should be able to drive it with the motor shield or any other motor driver. You would connect one side of the coil to ground and the other side to an output of the motor driver shield. Now whenever that output goes high the relay will switch on. You can control the relay by commanding the corresponding 'motor' to move or stop.

If you are only driving the relays you could also just use a simple MOSFET to control the relay coil as an alternative to the motor shield. If you have multiple relays you could likely stack the coils and so long as you have the voltage to drive the 2-3 coils you could control them with one output and guarantee they switch together.

Would I just connect the coms (the middle pin on the side with three) to a pinout on the board?
P.S. If I was attempting to wire three batteries as shown in the diagram rather than two would I need another two relays? The end result here is to change three batteries from a serial wire up to parallel in order to charge them safely without any human interaction. I need the wiring to change independently using the arduino based off of a timer function.

For every additional battery you add you will need two more poles of relay. So if you have SPDT relays this would be another two relays. One relay pole will disconnect the ground of the battery while the other pole will move the positive wire from the charger's positive output to the previous cells - side.

I don't quite understand what you are getting at with the coms pin?

This is a good tutorial on hooking a relay to an Arduino. I did exactly this just the other day to show someone.

(Don't tell anyone but I forgot the flyback diode with no ill effect but that's just my good fortune. You must put it in. Note that it's "backwards" in the sense that the diode cathode is on the + side of the supply)