Is the end that goes inside the tub spout threaded or smooth?
If it is threaded, there was no reason to remove it from the wall.
It looked smooth in the picture.
So if so, my bad, sorry.
My eyes are blurry today.
If it is threaded, your plan should work.
As long as the new spout has a threaded receiver of the same diameter, and same distance from the tile wall.
The end that goes into the wall looks to have a female fitting.
If that is right, you will have to try to wrap teflon tape around the male threads that are deep inside the wall.
Or, put generous teflon pipe dope on those male threads, and also on the female threads of the fitting you are screwing on.