• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Expert ,
Jan 24, 2024 Jan 24, 2024

Copy link to clipboard

Copied

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

TOPICS
Actions and scripting

Views

233

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Jan 24, 2024 Jan 24, 2024

Copy link to clipboard

Copied

@thomas_bredenfeld 

 

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

 

 
The following script is often cited, however from memory it has issues that I can't remember, but perhaps worth a try as well:
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 25, 2024 Jan 25, 2024

Copy link to clipboard

Copied

@Stephen_A_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 ...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jan 25, 2024 Jan 25, 2024

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 25, 2024 Jan 25, 2024

Copy link to clipboard

Copied

thanks a lot for this hint, @jazz-y
this is indeed my showstopper.
i'll check this against ps cc 2023 which i've installed too.
are you able to read the file binaries via JSX or do you need external tech here, like PHP or python?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jan 25, 2024 Jan 25, 2024

Copy link to clipboard

Copied

quoteare you able to read the file binaries via JSX or do you need external tech here, like PHP or python?

By @thomas_bredenfeld

jsx has tools for reading binary data. Yes, there are some limitations that affect the speed of obtaining the necessary data, however, when writing scripts, I prefer to stay within the extendScript to ensure maximum compatibility with Photoshop and the operating system.

 
 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 31, 2024 Jan 31, 2024

Copy link to clipboard

Copied

yes, i found out where in the metadata part of a psd file the smSMOo file path is living. but unfortunately only  is valid for SMOs living on the top level of the layer stack. nested SMOs aren't visible there 😞

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 24, 2024 Jan 24, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 25, 2024 Jan 25, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 25, 2024 Jan 25, 2024

Copy link to clipboard

Copied

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-...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 25, 2024 Jan 25, 2024

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 31, 2024 Jan 31, 2024

Copy link to clipboard

Copied

LATEST

thank you, @Stephen_A_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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines