Skip to main content
Bumped by Community user
Bumped by Community user
minor adjustment to provided script
Source Link

Please help :)

In Photoshop CC under "File > Place Linked..." I can select a file to be placed as a linked layer (layer with a link icon over the layer thumbnail). I would like a Photoshop script to do this same process with a predetermined file path. To clarify, I do not want an embedded smart object. It must be linked to the file so if there are changes to the original linked file I can go to Menu: "Layer > Smart Objects > Update All Modified Content" and it will update the linked layer with the any new changes. The layer should look like this:

enter image description here

I was able to add a layer, convert it to a smart object, and replace it with a provided file. Only thing left is to have it be a linked layer rather than an embedded smart object.

If more info/screen shots are required please reach out, Any help is greatly appreciated!


var convertToSmartObject = function () {
    var idnewPlacedLayer = stringIDToTypeID('newPlacedLayer');
    executeAction(idnewPlacedLayer, undefined, DialogModes.NO);
};
var replaceSmartObjectContents = function (aFilefilePath, smartObj) {
    app.activeDocument.activeLayer = smartObj;
    var idplacedLayerReplaceContents = stringIDToTypeID("placedLayerReplaceContents");
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID("null");
    desc3.putPath(idnull, new File(aFilefilePath));
    var idPgNm = charIDToTypeID("PgNm");
    desc3.putInteger(idPgNm, 1);
    executeAction(idplacedLayerReplaceContents, desc3, DialogModes.NO);
};
var doc = app.activeDocument;

// Add a layer, this will now be the active layer
doc.artLayers.add();  

// Convert active layer to Smart Object
convertToSmartObject(); 

// replace a provided layer with a provided file path
replaceSmartObjectContents(new File("~/Path/To/File.ai"), doc.activeLayer);

Please help :)

In Photoshop CC under "File > Place Linked..." I can select a file to be placed as a linked layer (layer with a link icon over the layer thumbnail). I would like a Photoshop script to do this same process with a predetermined file path. To clarify, I do not want an embedded smart object. It must be linked to the file so if there are changes to the original linked file I can go to Menu: "Layer > Smart Objects > Update All Modified Content" and it will update the linked layer with the any new changes. The layer should look like this:

enter image description here

I was able to add a layer, convert it to a smart object, and replace it with a provided file. Only thing left is to have it be a linked layer rather than an embedded smart object.

If more info/screen shots are required please reach out, Any help is greatly appreciated!


var convertToSmartObject = function () {
    var idnewPlacedLayer = stringIDToTypeID('newPlacedLayer');
    executeAction(idnewPlacedLayer, undefined, DialogModes.NO);
};
var replaceSmartObjectContents = function (aFile, smartObj) {
    app.activeDocument.activeLayer = smartObj;
    var idplacedLayerReplaceContents = stringIDToTypeID("placedLayerReplaceContents");
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID("null");
    desc3.putPath(idnull, new File(aFile));
    var idPgNm = charIDToTypeID("PgNm");
    desc3.putInteger(idPgNm, 1);
    executeAction(idplacedLayerReplaceContents, desc3, DialogModes.NO);
};
var doc = app.activeDocument;

// Add a layer, this will now be the active layer
doc.artLayers.add();  

// Convert active layer to Smart Object
convertToSmartObject(); 

// replace a provided layer with a provided file
replaceSmartObjectContents(new File("~/Path/To/File.ai"), doc.activeLayer);

Please help :)

In Photoshop CC under "File > Place Linked..." I can select a file to be placed as a linked layer (layer with a link icon over the layer thumbnail). I would like a Photoshop script to do this same process with a predetermined file path. To clarify, I do not want an embedded smart object. It must be linked to the file so if there are changes to the original linked file I can go to Menu: "Layer > Smart Objects > Update All Modified Content" and it will update the linked layer with the any new changes. The layer should look like this:

enter image description here

I was able to add a layer, convert it to a smart object, and replace it with a provided file. Only thing left is to have it be a linked layer rather than an embedded smart object.

If more info/screen shots are required please reach out, Any help is greatly appreciated!


var convertToSmartObject = function () {
    var idnewPlacedLayer = stringIDToTypeID('newPlacedLayer');
    executeAction(idnewPlacedLayer, undefined, DialogModes.NO);
};
var replaceSmartObjectContents = function (filePath, smartObj) {
    app.activeDocument.activeLayer = smartObj;
    var idplacedLayerReplaceContents = stringIDToTypeID("placedLayerReplaceContents");
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID("null");
    desc3.putPath(idnull, new File(filePath));
    var idPgNm = charIDToTypeID("PgNm");
    desc3.putInteger(idPgNm, 1);
    executeAction(idplacedLayerReplaceContents, desc3, DialogModes.NO);
};
var doc = app.activeDocument;

// Add a layer, this will now be the active layer
doc.artLayers.add();  

// Convert active layer to Smart Object
convertToSmartObject(); 

// replace a provided layer with a provided file path
replaceSmartObjectContents("~/Path/To/File.ai", doc.activeLayer);

Source Link

Photoshop script to take a Smart Object and "Relink to File"

Please help :)

In Photoshop CC under "File > Place Linked..." I can select a file to be placed as a linked layer (layer with a link icon over the layer thumbnail). I would like a Photoshop script to do this same process with a predetermined file path. To clarify, I do not want an embedded smart object. It must be linked to the file so if there are changes to the original linked file I can go to Menu: "Layer > Smart Objects > Update All Modified Content" and it will update the linked layer with the any new changes. The layer should look like this:

enter image description here

I was able to add a layer, convert it to a smart object, and replace it with a provided file. Only thing left is to have it be a linked layer rather than an embedded smart object.

If more info/screen shots are required please reach out, Any help is greatly appreciated!


var convertToSmartObject = function () {
    var idnewPlacedLayer = stringIDToTypeID('newPlacedLayer');
    executeAction(idnewPlacedLayer, undefined, DialogModes.NO);
};
var replaceSmartObjectContents = function (aFile, smartObj) {
    app.activeDocument.activeLayer = smartObj;
    var idplacedLayerReplaceContents = stringIDToTypeID("placedLayerReplaceContents");
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID("null");
    desc3.putPath(idnull, new File(aFile));
    var idPgNm = charIDToTypeID("PgNm");
    desc3.putInteger(idPgNm, 1);
    executeAction(idplacedLayerReplaceContents, desc3, DialogModes.NO);
};
var doc = app.activeDocument;

// Add a layer, this will now be the active layer
doc.artLayers.add();  

// Convert active layer to Smart Object
convertToSmartObject(); 

// replace a provided layer with a provided file
replaceSmartObjectContents(new File("~/Path/To/File.ai"), doc.activeLayer);