# Select background using batchPlay

**URL:** <https://forums.creativeclouddeveloper.com/t/select-background-using-batchplay/6666>\
**Category:** UXP Plugin API\
**Created:** [August 11, 2023, 11:06am UTC](https://forums.creativeclouddeveloper.com/t/select-background-using-batchplay/6666 "2023-08-11T11:06:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tais993](https://avatars.discourse-cdn.com/v4/letter/t/d78d45/32.png) [@Tais993](https://forums.creativeclouddeveloper.com/u/Tais993)\
**Post date:** [August 11, 2023, 11:06am UTC](https://forums.creativeclouddeveloper.com/t/select-background-using-batchplay/6666/1 "2023-08-11T11:06:29Z")

</div>

Heya,

Using Alchemist I created the underlaying command, which selected the background for me.  
This is required to align the item I’m copying into the document to the centre.

But I noticed, Photoshop also translated default layer names when using another language…

To counter that, I thought I could rename the background layer, but this caused it to not be the background anymore, and it seems that has caused other issues with the rest of the script.

```auto
async function selectCommand() {
    return await action.batchPlay(
        [

            {
                _obj: "select",
                _target: [
                    {
                        _ref: "layer",
                        _name: "Background"
                    }
                ],
                selectionModifier: {
                    _enum: "selectionModifierType",
                    _value: "addToSelection"
                },
            }
        ],
        {
            modalBehavior: "execute"
        }
    );
}

```

So to return to the original issue, I wanna go back to what I had before, but then properly select the background regardless of localisation.

So is there a way to select the background, like above, but without using the name?

---

<div class="post-metadata">

**Author:** ![tomzag](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/tomzag/32/2464_2.png) [@tomzag](https://forums.creativeclouddeveloper.com/u/tomzag)\
**Post date:** [August 11, 2023, 2:03pm UTC](https://forums.creativeclouddeveloper.com/t/select-background-using-batchplay/6666/2 "2023-08-11T14:03:44Z")

</div>

You could get the background layer id with:

```auto
const backgroundLayerID = app.activeDocument.backgroundLayer.id;

```

and then select the layer by id with:

```auto
async function selectCommand(id) {
    return await action.batchPlay(
        [

            {
                _obj: "select",
                _target: [
                    {
                        _ref: "layer",
                        _id: id
                    }
                ],
            }
        ],
        {}
    );
}

```

Or the easiest way without batchPlay:

```auto
app.activeDocument.backgroundLayer.selected = true;

```

---

<div class="post-metadata">

**Author:** ![Tais993](https://avatars.discourse-cdn.com/v4/letter/t/d78d45/32.png) [@Tais993](https://forums.creativeclouddeveloper.com/u/Tais993)\
**Post date:** [August 14, 2023, 7:56am UTC](https://forums.creativeclouddeveloper.com/t/select-background-using-batchplay/6666/3 "2023-08-14T07:56:52Z")

</div>

> Or the easiest way without batchPlay:

```auto
app.activeDocument.backgroundLayer.selected = true;

```

I was overthinking this LOL
