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

Batch processing Replace Linked image

Explorer ,
Nov 24, 2024 Nov 24, 2024

Copy link to clipboard

Copied

I have a template for my design. Base (template) design has 3 linked psd. (XXX bg, XXX obj, XXX design.)

xxx01.png

 

I'am copy for too many times bg fruit.tif file. After opening bg fruit.tif file which is new location. I need to relink 3 linked psd. Name is not the same, but end of the names are same.xxx02.png

 

My dream is this. After i open bg fruits.tif file. Search and auto Relink with the same end of the name.

Sorry for my English. I am trying to improve. Thanks for your helpings.

TOPICS
Windows

Views

159

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

correct answers 1 Correct answer

Community Expert , Nov 26, 2024 Nov 26, 2024

@Laf Tasarim Ofisi 

 

Give the following code a try...

 

The script will prompt you to select one or more TIFF files to open, bypassing the missing links dialog window...

 

2024-11-27_11-16-25.png

Next, the script will then loop over the 3 named linked smart object layers, relinking them to the new asset based on the name of the parent directory.

 

So, the placeholder XXX design.psd will be relinked to BAHRAIN APPLE design.psd or ACAI design.psd etc. Same for the XXX obj.psd and XXX bg.psd placeholder files. All insta

...

Votes

Translate

Translate
Adobe
Community Expert ,
Nov 24, 2024 Nov 24, 2024

Copy link to clipboard

Copied

@Laf Tasarim Ofisi 

 

The linked image path in your screenshots is different between the two examples.

 

I expected both to be in the same directory/folder path, just with different names. So, is the new name always in the same directory/folder, or does this change?

 

A custom script could probably be created to solve your problem.

 

What is the expectation, that you would be able to select a new folder and the links would auto update based on the back part of their names? How would this work for batch processing?

 

Can you list step-by-step what you wish to achieve? You can post in your native language and we can use the forum or other translation software if that is easier.

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
Explorer ,
Nov 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

WorkflowWorkflow

 

Apologies for the confusion. I have 100 fruit products, and I have one template for each of them called "bg fruit." Inside this "bg fruit" document, there are 3 placeholders (for future relinking). According to my design workflow, fruit designs will replace these placeholders. I adjust their alignment, quantity, and size all at once.

 

Then, I copy the "bg fruit" document prepared in a single file and paste it into 100 folders. These folders are named ACAI, BANANA, CHERRY, etc.

 

When I open the duplicate "bg fruit" document in the ACAI folder, I relink it with the files in the ACAI folder. Ta-da! Thanks to 3 relinks, the ACAI design template is set up. Then, I go into the BANANA folder, and this time, I relink the 3 placeholders with the 3 banana files in the BANANA folder.

 

What I want is this: When I open the "bg fruit" file in the ACAI folder, it will be automatically match with the files already present in the folder. In other words, I want the relink process to happen automatically.

 

If this seems complex, I can upload the file structure for you.

@Stephen Marsh 

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 ,
Nov 25, 2024 Nov 25, 2024

Copy link to clipboard

Copied

@Laf Tasarim Ofisi 

 

Thank you for the diagram and explanation, it does help. A custom script should be able to streamline your workflow.

 

I would need at least 2 examples to test. They don't need to be full high resolution, but in all other aspects they should be the same as used for production.

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
Explorer ,
Nov 26, 2024 Nov 26, 2024

Copy link to clipboard

Copied

Here you go. This is my file stracture.
You can download it directly on my ftp.
https://www.laf.com.tr/test.zip

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 ,
Nov 26, 2024 Nov 26, 2024

Copy link to clipboard

Copied

LATEST

@Laf Tasarim Ofisi 

 

Give the following code a try...

 

The script will prompt you to select one or more TIFF files to open, bypassing the missing links dialog window...

 

2024-11-27_11-16-25.png

Next, the script will then loop over the 3 named linked smart object layers, relinking them to the new asset based on the name of the parent directory.

 

So, the placeholder XXX design.psd will be relinked to BAHRAIN APPLE design.psd or ACAI design.psd etc. Same for the XXX obj.psd and XXX bg.psd placeholder files. All instances of the base three linked files of the same name will be updated.

 

The open file will then be saved and closed, before the next file is opened and the process is repeated until all selected files to open have been processed.

 

/*
Relink Named Smart Objects to Parent Folder.jsx
Stephen Marsh
v1.0, 27th November 2024
https://community.adobe.com/t5/photoshop-ecosystem-discussions/batch-processing-replace-linked-image/td-p/15000552
*/

#target photoshop;

// Skip the open dialog warnings
var savedDisplayDialogs = app.displayDialogs;
app.displayDialogs = DialogModes.NO;

// Hide the Photoshop panels
app.togglePalettes();

// Select multiple files to open (ignoring warnings)
var fileOrFiles = File.openDialog("Select the TIFF file/s to open:", Multiselect = true);

// Create the progress bar window
var win = new Window("palette", "Progress", [150, 150, 600, 270]);
var progressBar = win.add("progressbar", [20, 12, 430, 24], 0, fileOrFiles.length);
var progressText = win.add("statictext", [10, 30, 440, 48], "Processing files...");
progressText.alignment = "center";
win.center();
win.show();

// Loop over the selected files
for (var i = 0; i < fileOrFiles.length; i++) {
    // Update the progress bar
    progressBar.value = i + 1;
    progressText.text = "Processing file " + (i + 1) + " of " + fileOrFiles.length;
    win.update();

    // Open the file and get the active document
    var openFiles = app.open(File(fileOrFiles[i]));

    // Set the doc path variables
    var parentPath = app.activeDocument.path.fsName;
    var fruitName = parentPath.replace(/(^.+\/)(.+$)/, "$2");

    // Update the linked "design" smart objects
    selectLayerByName("XXX design");
    relinkToFile(parentPath + "/" + fruitName + " design.psd");
    // Update the linked "obj" smart objects
    selectLayerByName("XXX obj");
    relinkToFile(parentPath + "/" + fruitName + " obj.psd");
    // Update the linked "bg" smart objects
    selectLayerByName("XXX bg");
    relinkToFile(parentPath + "/" + fruitName + " bg.psd");

    // End of link update alert
    app.beep();

    // Close and save
    app.activeDocument.close(SaveOptions.SAVECHANGES);
}

// Close the progress bar window
app.bringToFront();
win.close();

// End of script alert
alert("Script completed!");

// Restore the Photoshop panels
app.togglePalettes();
app.displayDialogs = savedDisplayDialogs;


function selectLayerByName(layerName) {
    var s2t = function (s) {
        return app.stringIDToTypeID(s);
    };
    var descriptor = new ActionDescriptor();
    var list = new ActionList();
    var reference = new ActionReference();
    reference.putName(s2t("layer"), layerName);
    descriptor.putReference(s2t("null"), reference);
    descriptor.putBoolean(s2t("makeVisible"), false);
    descriptor.putList(s2t("layerID"), list);
    executeAction(s2t("select"), descriptor, DialogModes.NO);
}

function relinkToFile(filePath) {
    var idplacedLayerRelinkToFile = stringIDToTypeID("placedLayerRelinkToFile");
    var desc431 = new ActionDescriptor();
    var idnull = stringIDToTypeID("null");
    desc431.putPath(idnull, new File(filePath));
    executeAction(idplacedLayerRelinkToFile, desc431, DialogModes.NO);
}

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

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