How to get the Smart object linked file location

Explorer ,
Apr 19, 2022 Apr 19, 2022

Copy link to clipboard

Copied

 

Hi everyone,

what a learning curve with this photoshop integration. It is very interesting but also a little bit frustrating.

I got some smart objects and the end goal is to change the linked file locations.

But first I need to know what the current location is.

Has anyone got some very simple code that does it?

Even better if it is VBScript or a bonus point for vb.net but I will take what I can get.

Thanking you very kindly.

Henry

TOPICS
Actions and scripting

Views

177

Likes

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

Explorer , Apr 22, 2022 Apr 22, 2022
Firstly thanks to everyone for your help. It was a very painful process but without your help it would of been impossible. I followed the links over to (https://community.adobe.com/t5/photoshop-ecosystem-ideas/is-there-an-option-that-shows-me-a-list-with-all-smart-objects-paths/idc-p/12689475)went through the jscript(??) and slowly translated it vb.net. Very interesting language, very easy to follow. I thought it might be helpful to other people so I posted my code.  top of the class imports pho...

Likes

Translate

Translate
Adobe Community Professional ,
Apr 19, 2022 Apr 19, 2022

Copy link to clipboard

Copied

I am not script guy. There is requested info on Window > Properties panel, just ensure that linked Smart Object is selected in the Layers panel then  open Window > Properties and you should see file location.

linked sm location.jpg

Likes

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 ,
Apr 19, 2022 Apr 19, 2022

Copy link to clipboard

Copied

Actually, I did not know that. I was always baffled on how to see that.  That will come in handy.

But need to be able to script the whole thing. Something like 30 objects per page x 40 something pages and growing. 

Just silly for me to manually.

 

Likes

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 Professional ,
Apr 20, 2022 Apr 20, 2022

Copy link to clipboard

Copied


@henry22453428ow9z wrote:

I got some smart objects and the end goal is to change the linked file locations.

But first I need to know what the current location is.

Has anyone got some very simple code that does it?



 
A simplistic JS approach for a single active SO layer (this would need to be looped over multiple layers):
app.runMenuItem(stringIDToTypeID('placedLayerEditContents'));
alert(decodeURI(activeDocument.path) + "/" + activeDocument.name);
 
Perhaps the following topic is what you are after:
 
EDIT: While I'm at it, this is also possible with ExifTool:
exiftool -XMP-xmpMM:IngredientsFilePath 'Mac path to/file.psd'

or

exiftool -IngredientsFilePath "Win path to\file.psd"

Likes

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 ,
Apr 22, 2022 Apr 22, 2022

Copy link to clipboard

Copied

Firstly thanks to everyone for your help. It was a very painful process but without your help it would of been impossible. 

I followed the links over to (https://community.adobe.com/t5/photoshop-ecosystem-ideas/is-there-an-option-that-shows-me-a-list-wit...

went through the jscript(??) and slowly translated it vb.net. Very interesting language, very easy to follow. I thought it might be helpful to other people so I posted my code. 

 

top of the class
imports photoshop  


following in a button action, class, function  etc...

      Dim ref
        Dim applicationDesc
        Dim theNumber
        Dim layerDesc
        Dim isSmartObject
        Dim theSO
        Dim theLink
        Dim ps_app As New Photoshop.Application
        ref = New ActionReference
        ref.putProperty(ps_app.StringIDToTypeID("property"), ps_app.StringIDToTypeID("numberOfLayers"))
        ref.putEnumerated(ps_app.CharIDToTypeID("Dcmn"), ps_app.CharIDToTypeID("Ordn"), ps_app.CharIDToTypeID("Trgt"))
        applicationDesc = ps_app.ExecuteActionGet(ref)
        theNumber = applicationDesc.getInteger(ps_app.StringIDToTypeID("numberOfLayers"))

        Dim m = 0
        Dim n = 0

        Do While m <= theNumber
            ref = New ActionReference ' might fall over as it is already declared above
            ref.putIndex(ps_app.CharIDToTypeID("Lyr "), m)
            layerDesc = ps_app.ExecuteActionGet(ref)
            isSmartObject = layerDesc.hasKey(ps_app.StringIDToTypeID("smartObject"))

            If isSmartObject = True Then
                theSO = layerDesc.getObjectValue(ps_app.StringIDToTypeID("smartObject"))
                If theSO.getBoolean(ps_app.StringIDToTypeID("linked")) = True Then
                    theLink = theSO.getPath(ps_app.StringIDToTypeID("link")) ' this will give the path
                End If
            End If

            m = m + 1
        Loop

 

Likes

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
LEGEND ,
Apr 22, 2022 Apr 22, 2022

Copy link to clipboard

Copied

Nice job - thanks for sharing vbscript code, unusual for this forum!

 

Moderator - remove extra ')' character from end of link posted by user.

Likes

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 ,
Apr 23, 2022 Apr 23, 2022

Copy link to clipboard

Copied

LATEST

Yeah, I have not seen much vb code here. There was a bit of a learning process and as I looked over the scripting guide, it seemed so simple and straightforward. But I guess once you know then you know.

Good luck to the next vb scripter, hopefully I have been helpful and given a little bit back.

 

Likes

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
LEGEND ,
Apr 20, 2022 Apr 20, 2022

Copy link to clipboard

Copied

sTT = stringIDToTypeID; (ref = new ActionReference())
.putProperty(sTT('property'), sO = sTT('smartObject'))
ref.putEnumerated(sTT('layer'), sTT('ordinal'), sTT('targetEnum'))
executeActionGet(ref).getObjectValue(sO).getPath(sTT('link')).fsName

Likes

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