Distributed battery systems (DBS) are widely used in microgrids to compensate imbalanced active and reactive power flows, and for stabilizing bus voltages of microgrids with a high penetration of renewable energy sources (RES). In this paper, a particle-swarm-optimization (PSO) method is adopted as the secondary control of DBS in a standalone AC microgrid. The fitness function of the PSO algorithm contains the parameters of the bus voltage deviations and the power losses on the distribution lines. Through iteration, the bus voltage deviations and the power losses on the distribution lines are reduced, simultaneously. Importantly, the State-of-Charges (SOC) of the battery packs are also being taken into consideration and the battery packs are controlled by local controllers to prevent deep-discharge and over-charge. Both results from Matlab simulation and Real-Time Digital Simulator (RTDS) validate the effectiveness of the proposed control scheme in concurrently reducing the distribution power losses and meeting bus voltage regulations in AC microgrids.