Your knowledge of electricity and electrical system will have a lot to do with the options you may have. BUT - if you think 4-12V batteries in parallel give one 48 Volts, you need to brush up on a bit of elementary electrical theory.
There can be several ways. One will be to change the connections from series (48V) to parallel and charge. Then when they are charged, switch back to series and hook back up to the UPS. This will probably require a bunch of switches and be a real pain.
A voltage booster may also be used.
You should be informed many have found a UPS is not an efficient method of conversion of DC to AC and most have a lot of problems. A good 'Google search' of the board will being up many posts about UPS units as inverters.
Personally, I don't thing there is a good way to do what you propose unless you have a free source of power.
Ron