Yes, you would need to run your script through a while loop and prompt a user selection and run a task on each iteration. Opening and closing the transaction each time. You could use a cancellation to end the process. I’m fairly sure this would work, but haven’t tried looping with a transaction before in a while loop.
Try this as a base for your loop process, and put your function within the loop body: