There has been a similar question back in 2015 which was answered here: Set origin to bottom center of multiple objects
However time has passed and those scripts no longer seem to be working.
Here's what I'm trying to achieve. I have a scene in Blender with a large amount of tree objects. I want to introduce a few more types of trees into the mix by selecting some of the existing trees and replacing them with Ctrl+L > Link object data. However, because of the irregularity of the terrain they sit on and the difference in scale of these trees, the only reliable way to make sure I dont get floating or sunk trees after replacing is to have the very base of each tree as its origin. Scale after replacement is irrelevant, I can randomize it and it looks good enough.
I'm asking for either a script that can do the above or new ideas on how I could go about replacing these objects. Thank you in advance.