# loadFilesIntoStack through Batchplay

**URL:** <https://forums.creativeclouddeveloper.com/t/loadfilesintostack-through-batchplay/9264>\
**Category:** Photoshop\
**Tags:** uxp\
**Created:** [February 12, 2025, 11:38am UTC](https://forums.creativeclouddeveloper.com/t/loadfilesintostack-through-batchplay/9264 "2025-02-12T11:38:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fred](https://avatars.discourse-cdn.com/v4/letter/f/db5fbb/32.png) [@fred](https://forums.creativeclouddeveloper.com/u/fred)\
**Post date:** [February 12, 2025, 11:38am UTC](https://forums.creativeclouddeveloper.com/t/loadfilesintostack-through-batchplay/9264/1 "2025-02-12T11:38:23Z")

</div>

Hi, I want to “loadFilesIntoStack” the 2 opened documents. Is there a way to have the “ **Add Open Files** ” and “ **Attempt to Automatically Align Source Images** ” already set in the code (not with the popup window).  
Thanks,  
fred

```auto
   async function TEST() {
      let commands = [
          // Scripts
          {
              "_obj": "AdobeScriptAutomation Scripts",
              "javaScriptMessage": {
                _obj: "loadFilesIntoStack",
                _target: [
                    {
                        _ref: "document",
                        _id: documentIds[0]
                    },
                    {
                        _ref: "document",
                        _id: documentIds[1]
                    }
                ]
            },
              "javaScriptName": "Load Files into Stack..."
          }
      ];
      
      return await require("photoshop").action.batchPlay(commands, {});
  }
  const openDocuments = await app.documents;
  const documentIds = openDocuments.slice(0, 2).map(doc => doc.id);

  const result = await require("photoshop").core.executeAsModal(TEST, {"commandName": "Action Commands"})
  console.log("documentIds", documentIds)

```
