# Loop through batch pla

**URL:** <https://forums.creativeclouddeveloper.com/t/loop-through-batch-pla/5249>\
**Category:** Photoshop\
**Tags:** batch-play\
**Created:** [September 19, 2022, 3:09pm UTC](https://forums.creativeclouddeveloper.com/t/loop-through-batch-pla/5249 "2022-09-19T15:09:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![leigh765](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/leigh765/32/2357_2.png) [@leigh765](https://forums.creativeclouddeveloper.com/u/leigh765)\
**Post date:** [September 19, 2022, 3:09pm UTC](https://forums.creativeclouddeveloper.com/t/loop-through-batch-pla/5249/1 "2022-09-19T15:09:47Z")

</div>

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:

```auto
 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

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [September 19, 2022, 9:55pm UTC](https://forums.creativeclouddeveloper.com/t/loop-through-batch-pla/5249/2 "2022-09-19T21:55:07Z")

</div>

So where’s the loop?
