Batteries are excluded for good reason. The device and battery can be a fire hazard. It needs to be capable of surviving high temperatures and pressures. The risk of any kind of electrical fault inside the recorder also needs to be exactly 0.
That's not all though. The boxes cannot actually get any data. The data needs to be sent to the black boxes from other sensors throughout the aircraft. So if the power to the blackbox is cut, it's likely that there is no power to the aircraft in general. That means there is no point in continuing to record. If we do include batteries, those batteries need to be able to power all relevant systems on the aircraft itself.
Also, technically flight recorders already have batteries. But those batteries are usually reserved for the locator beacons. Not recording. They are also located outside the black box itself. (although they are attached together and installed as one device.
That's not all though. The boxes cannot actually get any data. The data needs to be sent to the black boxes from other sensors throughout the aircraft. So if the power to the blackbox is cut, it's likely that there is no power to the aircraft in general. That means there is no point in continuing to record. If we do include batteries, those batteries need to be able to power all relevant systems on the aircraft itself.
Also, technically flight recorders already have batteries. But those batteries are usually reserved for the locator beacons. Not recording. They are also located outside the black box itself. (although they are attached together and installed as one device.