Using a 5V Optical Mouse USB Cable to Power a toy requiring 4 Size D batteries
I would have a bit of a reservation about powering a baby swing from a random wall-wart supply. Normally, of course, such supplies work fine, and the baby isn't supposed to touch other grounded surfaces, but the swing wasn't really designed for it.
There are two areas of concern:

Electrical Safety
If your supply's isolation fails, you might have a dangerous situation as the baby is normally strapped into the swing. A grounded adult touching such a swing might then electrocute themselves and/or the baby.

Physical Safety
The supply cord becomes a nice strangulation hazard. Make sure that it's properly zip-tied to the supporting structure and routed out of reach of the baby!


When it comes to devices that are in forced, constant contact with the body, such as in a baby swing, I'd not use a random supply, but buy a medical grade power supply, such as this one. It's only $15 at this time + shipping.
Before you spend on such a supply, it'd be worthwhile to calculate how much money you're going to save in batteries over the life of the device. I'd also not randomly switch over to rechargeable batteries: they can be a real fire hazard in devices not designed (read: at least fused) to accommodate them.