Unfortunately I doesn't work, as I quickly get a warning from the script. If I choose "continue", Thunderbird is not responding anymore (even if kept running for hours).
How long did you wait? If the script isn't locking up and is just busy the whole time, you might not be waiting long enough. You might have to wait over 24 hours for example. Not saying that's comforting, but you can try waiting way longer.
Before you try again though, in "Options -> Advanced -> General -> Config editor", add/set dom.max_chrome_script_run_time to 0 so Thunderbird never complains about the script being busy. See http://kb.mozillazine.org/Dom.max_script_run_time.