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
Copy link to clipboard
Copied
I can't recall if the folling script from @jazz-y works with nested files, but it's worth a try:
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 ...
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.
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?
Copy link to clipboard
Copied
are 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.
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 😞
Copy link to clipboard
Copied
Could you please post screenshots with the pertinent Panels visible to illustrate the Layer/SO- and the File-structure?
Copy link to clipboard
Copied
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.
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.
Copy link to clipboard
Copied
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.