Battery-powered locomotives just aren't going to work. Period.
Nor will hydrogen-powered locomotives -- not reliably or efficiently, anyway.
Who here has read William D. Middleton's books "When the Steam Railroads Electrified", or "Time of the Trolley"?
In the earliest days of electric traction (which go all the way back to 1834 or so and Thomas Davenport's little electric toy locomotive in Vermont) one of the fundamental problems became a constant source of electric power.
Electrical dynamos that were reliable didn't yet exist, so batteries were used. Very crude then, of course, but they demonstrated 175 years ago why "batteries" could not be relied upon for powering railed vehicles over any distances or for any extended length of time.
Once a "constant source of power" was established (electric dynamo generator at a fixed power plant) and a good source of power delivery was fabricated (third rail or overhead wire), electric traction proceeded rapidly.
By the 1920's, railroads had established reliable and well-performing alternatives to steam power -- by electrifying their mainlines, such as the New Haven, The Milwaukee Road, and [a decade+ later] the Pennsylvania.
If the railroads are going to replace diesel-electric locomotives in mainline freight service, all they have to do is electrify those mainlines. NOW they'll have a constant source of power that won't run down and require "re-charging" -- from the nearly-limitless power in the wire up above.
I realize "the cost" of such services. It won't be cheap.
But this is the only scheme that will work.
Perhaps if a state like California had given up notions of that stupid "high-speed rail" boondoggle that has burned up tens of BILLIONS in that state, and put all those funds toward electrifying the freight mainlines, they would actually have something to show for their money, and something that cuts down on diesel usage, as well.
But batteries?
Not gonna happen in your lifetime.