Loop through batch pla

I am creating a plugin where I loop through document and:

  • open
  • resize
  • make canvas larger
  • batch play a template on image

When I loop through the docs I get
VM13909 common.js:103 Too many modal scope commands
I have tried to await the batchPlay but it blows right pass it. Any ideas?

here is my code:

 async createAssetsSlide(file, folder) {
        await executeAsModal(async (executionContext) => {
            const filename = file.name.split(".")[0].toUpperCase();
            await psApp.open(file);

            if (psApp.activeDocument.height >= psApp.activeDocument.width) {
                await psApp.activeDocument.resizeImage(640 * psApp.activeDocument.width / psApp.activeDocument.height, 640)
            }
            if (psApp.activeDocument.height < psApp.activeDocument.width) {
                await psApp.activeDocument.resizeImage(1100, 1100 * psApp.activeDocument.height / psApp.activeDocument.width)
            }

            if (filename.includes("guide")) {

            } else {
                await psApp.activeDocument.resizeCanvas(1280, 720);
            }


            await batchPlay([
                await makeline({ left: 0, top: 55 }, { left: 1280, top: 55 }, { red: 226, blue: 226, green: 226 }),
                await addtext(500, 10, 2.5, 3, (folder.name.toUpperCase() + "   |   " + filename), 10),
                await addtext(80, 10, 26, 94.5, "PLATFORM", 14),
                await addtext(300, 10, 36, 94.5, "130 Arena Street El Segundo\, CA 90245   \|   310-401-2000  \|   platform.la", 8),
            ], {});
            await batchPlay([
                await makeline({ left: 300, top: 670 }, { left: 980, top: 670 }, { red: 226, blue: 226, green: 226 })
            ], {});
            await batchPlay([
                await makeline({ left: 450, top: 670 }, { left: 450, top: 720 }, { red: 226, blue: 226, green: 226 })
            ], {});
        }, { commandName: "Create Asset Slide" })
    }

Leigh

So where’s the loop?