I can't thank you enough. That script did both tasks perfectly on the first try! (I was expecting to need at least two separate scripts and multiple replies to the thread and having to to-and-fro several times!).
It's done exactly what I needed and you've saved me an enormous amount of work.