My friend, thank you very much for the script.
I made an edit and would like to share it, because I missed inserting the data into cq_task... so I made a modification to the script and wanted to share it with you.
Furthermore, I noticed that it did not generate the entire script and ended up crashing, as shown in your image. I fixed that too.
Try it and tell me if it works, thank you!