Photoshop Script Request – Relink Smart Objects by Filename
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.pngThe 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.pngNotice 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.pngThe 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.pngAfter running the script:
Card 1 → Deck B/14.png
Card 2 → Deck B/3.png
Card 3 → Deck B/27.pngThe 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:
- Ask me to select a folder.
- Read all image files in that folder.
- For every Smart Object, determine which image filename it currently contains.
- 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.pngChoose folder:
Deck BResult
Card 1 → Deck B/14.png
Card 2 → Deck B/3.png
Card 3 → Deck B/27.pngNo scaling.
No repositioning.
No fitting.
No cropping.
Only replace the Smart Object contents while preserving every existing transformation.
