Skip to main content
thomas_bredenfeld
Community Expert
Community Expert
January 24, 2024
Question

PS script for batch re-linking missing files in nested smart objects without "missing links" dialog

  • January 24, 2024
  • 4 replies
  • 1933 views

please allow a help request to all PS scripting aficionados here,

 

i have a bunch of PSD files (let's name them "main files" with their layers being "level 1") with some layers containing embedded (not linked!) smart objects. inside of this smart objects (level 2) i have some linked smart objects inside of a group (level 3). so they are nested. the files linked here are living strictly in a subfolder of the folder where the main files live. let's call these files "sub files".


i managed to write a script to batch update all main files after the content of the sub files are edited. this works fine with opening every main file, scanning all layers, finding the smart objects, opening them, diving into the group and finding the linked smart objects within and updating them.


as the folder with the main files needs to be re-usable and to be copied/moved elsewhere, i need to have a second script to be executed as a preparation for re-linking all of the absolute file paths of the linked smart objects.
i did a lot of research in this community and in other forums, but didn't find a solution yet. especially the "missing links" dialog popping up after opening the embedded smart object layers (level 1, see above) stops all scripts and i didn't find a way to mute this dialog and continue searching/replacing the file path infos by my script. muting dialogs and script alerts didn't help here. besides this everything happening inside of the "missing link" dialog obviously isn't reachable for the script listener plugin. i only see the dialog being opened, nothing else.

basically, i only need a script for silently relinking all sub files to a relocated space in a subfolder of the main files. as the sub folder always has the same name, the relinking script should be able to run automatically as it finds the main files folder name because it's running within.

 

sorry for this longish post/request and thanks for listening and for any hints
thomas

This topic has been closed for replies.

4 replies

thomas_bredenfeld
Community Expert
Community Expert
January 31, 2024

thank you, @Stephen Marsh , @c.pfaffenbichler  and @jazz-y for your hints and advices. i made some progress with simplifying my file and layer structure. a pretty interesting finding was that photoshop automatically updates SMO file paths in SMOs living in the top level of the layer stack. tests with moving projects to another folder and even transferring them from mac to windows are promising. i'll do some more tests and will report my results here.

Stephen Marsh
Community Expert
Community Expert
January 25, 2024

Here is a script for removing photoshop:DocumentAncestors metadata from nested smart objects. You could probably swap out the metadata code for the relinking code.

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/remove-documentancestors-recursively-for-all-smartobjects-in-a-psd/td-p/13043605#U13054410

thomas_bredenfeld
Community Expert
Community Expert
January 25, 2024

@Stephen Marsh thank you for this link! after a short 1st view i think there could be usable code chunks in it for my problem.

c.pfaffenbichler
Community Expert
Community Expert
January 25, 2024

Could you please post screenshots with the pertinent Panels visible to illustrate the Layer/SO- and the File-structure? 

thomas_bredenfeld
Community Expert
Community Expert
January 25, 2024

yes, of course. here you go. i hope it's clear enough to understand the 3 nesting levels.

Stephen Marsh
Community Expert
Community Expert
January 24, 2024

@thomas_bredenfeld 

 

I can't recall if the folling script from @jazz-y works with nested files, but it's worth a try:

 

thomas_bredenfeld
Community Expert
Community Expert
January 25, 2024

@Stephen Marsh thank you!
i found both of the quoted posts already during my reserach. the script of @jazz-y  works so far as it lists the missing files correctly, while the updating and relinking functions aren't working.
the link to the stack overflow was helping me to build up the batch update script i mentioned and which is working flawlessly as soon as all files are in place and no one is missing.
maybe i can reduce the nesting levels ...

Legend
January 25, 2024

Hi! If we are talking about linked layers in smart objects, then starting with version Photoshop 24.5, Adobe added a new warning dialog box when trying to open or convert to layers. It ruins the script and then it works incorrectly.

I found a workaround and made some code sketches (read the binary image file directly from disk, look for all links inside, create temporary files in the directory with the main file), but I don't have the ability to adapt the script yet.

 

If you install an earlier version of Photoshop (for example, 24.0), then the script should work correctly.