Skip to main content
Participant
July 27, 2026
Question

Photoshop Script Request – Relink Smart Objects by Filename

  • July 27, 2026
  • 1 reply
  • 16 views

I'm looking for a Photoshop script (JavaScript/ExtendScript or UXP) to automate my card deck mockup workflow.

My workflow

I create Tarot and Oracle card mockups.

Each PSD contains multiple Smart Objects representing cards arranged in a specific composition.

Each Smart Object already contains a card image from a folder.

For example:

 
Deck A/

1.png
2.png
3.png
...
56.png

The PSD already uses these images in different positions.

For example:

 
Card 1 → 14.png

Card 2 → 3.png

Card 3 → 27.png

Card 4 → 8.png

Notice that the Smart Object names are not related to the image filenames.

The composition has already been carefully designed.

What I want

I have another folder:

 
Deck B/

1.png
2.png
3.png
...
56.png

The filenames are identical.

The images are different.

I want to select the new folder and have the script automatically replace every Smart Object with the image that has the same filename currently used inside that Smart Object.

Example:

Current PSD

 
Card 1 → 14.png

Card 2 → 3.png

Card 3 → 27.png

After running the script:

 
Card 1 → Deck B/14.png

Card 2 → Deck B/3.png

Card 3 → Deck B/27.png

The only thing that changes is the source folder.

Very important

The script must preserve absolutely everything.

It should only replace the Smart Object contents.

It must preserve:

  • Smart Object transformation
  • Position
  • Scale
  • Rotation
  • Perspective
  • Effects
  • Layer hierarchy
  • Mask
  • Opacity
  • Blend mode

It should behave exactly like Photoshop's Replace Contents command.

Folder selection

The script should:

  1. Ask me to select a folder.
  2. Read all image files in that folder.
  3. For every Smart Object, determine which image filename it currently contains.
  4. Replace it with the image of the same filename from the selected folder.

Export

After replacing all Smart Objects, optionally export:

  • JPG
  • PNG

Example

Current mockup

 
Card 1 → 14.png
Card 2 → 3.png
Card 3 → 27.png

Choose folder:

 
Deck B

Result

 
Card 1 → Deck B/14.png
Card 2 → Deck B/3.png
Card 3 → Deck B/27.png

No scaling.

No repositioning.

No fitting.

No cropping.

Only replace the Smart Object contents while preserving every existing transformation.

    1 reply

    Stephen Marsh
    Community Expert
    Community Expert
    July 27, 2026

    @andgartis 

     

    You can start with these various scripts: