Highlighted

Obtain filename of referenced graphic

Community Beginner ,
Apr 17, 2019

Copy link to clipboard

Copied

I am trying to create a script that I can run individually on referenced graphics which would return me information on what file it is, and which document it is located in.

So far I have this script

var graphic = null;

var doc = app.ActiveDoc;

if(doc.ObjectValid() == true)

{

       graphic = doc.FirstSelectedGraphicInDoc;

      

       if(graphic.constructor.name != "Inset")

        {

            graphic = null;

            alert("inset not found");

        }

}

if(graphic != null && graphic.ObjectValid() == true)

{

    var promptMessage = "The currently-selected graphic is:\n\n" +

       graphic.Name +"\n\n" + doc.Name;

        alert(promptMessage);

    }

else

{

    alert("No active document or no referenced graphic selected. " +

        "Cannot continue.");

}

alert("script complete!");

Right now when I have a graphic selected it produces the alert which correctly tells me what document the file is in but says "undefined" in the space I expect to see the image filename.

What is the correct way to obtain this information?

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

The property you want on an imported graphic is not Name but InsetFile.

TOPICS
Scripting

Views

385

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

Obtain filename of referenced graphic

Community Beginner ,
Apr 17, 2019

Copy link to clipboard

Copied

I am trying to create a script that I can run individually on referenced graphics which would return me information on what file it is, and which document it is located in.

So far I have this script

var graphic = null;

var doc = app.ActiveDoc;

if(doc.ObjectValid() == true)

{

       graphic = doc.FirstSelectedGraphicInDoc;

      

       if(graphic.constructor.name != "Inset")

        {

            graphic = null;

            alert("inset not found");

        }

}

if(graphic != null && graphic.ObjectValid() == true)

{

    var promptMessage = "The currently-selected graphic is:\n\n" +

       graphic.Name +"\n\n" + doc.Name;

        alert(promptMessage);

    }

else

{

    alert("No active document or no referenced graphic selected. " +

        "Cannot continue.");

}

alert("script complete!");

Right now when I have a graphic selected it produces the alert which correctly tells me what document the file is in but says "undefined" in the space I expect to see the image filename.

What is the correct way to obtain this information?

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

The property you want on an imported graphic is not Name but InsetFile.

TOPICS
Scripting

Views

386

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
Apr 17, 2019 0
Adobe Community Professional ,
Apr 17, 2019

Copy link to clipboard

Copied

The property you want on an imported graphic is not Name but InsetFile.

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
Reply
Loading...
Apr 17, 2019 2