Highlighted

relink all selected

Adobe Community Professional ,
Sep 11, 2017

Copy link to clipboard

Copied

CarlosCanto​ wrote this script for me years ago, but seems to not work anymore on

Mac OS 10.10.5

CC2015.3

Is supposed to relink all instance of an image, as for example on a carton in packaging design we make have the same picture of an apple pie on all 6 sides. Is annoying to run the link panel 6 times rather than one command. This was further aggravated by the Mac OS not remember ing the last location, which default folder used to correct, but that seems to work now.

#target Illustrator

// script.name = relinkAllSelected.jsx;

// script.description = relinks all selected placed images at once;

// script.required = select at least one linked image before running;

// script.parent = CarlosCanto // 7/12/11;

// script.elegant = false;

var idoc = app.activeDocument;

sel = idoc.selection;

if (sel.length>0)

     {

       

          for (i=0 ; i<sel.length ; i++ )

               {

                   if (sel.typename == "PlacedItem")

                        {

    

                            var iplaced = sel;

       var file = File.openDialog ("open file " + iplaced.file );

                            iplaced.file = file;

                         }

               }

     }

else

     {

          alert("select at least one placed item before running");

     }

Most Valuable Participant
Correct answer by pixxxel_schubser | Most Valuable Participant

Oops

Moving a line before the variable was defined is never a good idea.

var file = File.openDialog ("open file " + iplaced.file );

should be

var file = File.openDialog ("open file ");

Topics

Scripting

Views

3.6K

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

relink all selected

Adobe Community Professional ,
Sep 11, 2017

Copy link to clipboard

Copied

CarlosCanto​ wrote this script for me years ago, but seems to not work anymore on

Mac OS 10.10.5

CC2015.3

Is supposed to relink all instance of an image, as for example on a carton in packaging design we make have the same picture of an apple pie on all 6 sides. Is annoying to run the link panel 6 times rather than one command. This was further aggravated by the Mac OS not remember ing the last location, which default folder used to correct, but that seems to work now.

#target Illustrator

// script.name = relinkAllSelected.jsx;

// script.description = relinks all selected placed images at once;

// script.required = select at least one linked image before running;

// script.parent = CarlosCanto // 7/12/11;

// script.elegant = false;

var idoc = app.activeDocument;

sel = idoc.selection;

if (sel.length>0)

     {

       

          for (i=0 ; i<sel.length ; i++ )

               {

                   if (sel.typename == "PlacedItem")

                        {

    

                            var iplaced = sel;

       var file = File.openDialog ("open file " + iplaced.file );

                            iplaced.file = file;

                         }

               }

     }

else

     {

          alert("select at least one placed item before running");

     }

Most Valuable Participant
Correct answer by pixxxel_schubser | Most Valuable Participant

Oops

Moving a line before the variable was defined is never a good idea.

var file = File.openDialog ("open file " + iplaced.file );

should be

var file = File.openDialog ("open file ");

Topics

Scripting

Views

3.6K

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
Adobe Community Professional ,
Sep 11, 2017

Copy link to clipboard

Copied

Have you thought of using the Illustrator variable data to help with this workflow?

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...
Adobe Community Professional ,
Sep 11, 2017

Copy link to clipboard

Copied

Would that help here? All I want to do is update 6 links of:

\Volumes\Kaleidoscope Server\1 Jobs\ABCD\AWG\79786 AWG Best Choice Ice Cream Range Design\5 Implementation\1 Images\Vanilla1.psd

to

\Volumes\Kaleidoscope Server\1 Jobs\ABCD\AWG\79786 AWG Best Choice Ice Cream Range Design\5 Implementation\1 Images\Vanilla2.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
Reply
Loading...
Adobe Community Professional ,
Sep 12, 2017

Copy link to clipboard

Copied

In your case, probably not. Or, probably may, depending if you find yourself needing to replace multiple images with different images!

You see, in a less-than-ideal workaround, you can save a spreadsheet .txt or .csv file with just these contents:

@my-image
newImage.png

The document's images you want to relink would need to be named "my-image" so they can be bound by name via VariableImporter.jsx

The thing is, you will need to change "newImage.png" to your new image name every time - so you'd have to keep this text file open and make edits to it throughout the day. The downsides are the spreadsheet, the clicks to open it inside VariableImporter dialog, but the upside is that your csv can be a nice spot to keep your latest used file path (instead of getting it from links panel), your placed files are all replaced at the same time, and if needed, you can actually relink multiple sets of placed files, using multiple @my-image-x columns.

Another thing is, I need to fix up the VariableImporter to remember name of last csv location used, so that you don't have to navigate to it every time. And, I have a bug which messes up server paths on Windows. So, I'll get back to you with the changes

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...
Adobe Community Professional ,
Sep 12, 2017

Copy link to clipboard

Copied

Thanks Sily-V. Variable data is one of the very few things I have not used much in illustrator. I pick up files form designers, and do not get a lot of time to make them print ready photo retouch and lay out all the panels to the die line, so seeing the script as a quicker solution.

Carlos or someone else may be able to figure out the script, but have not seen him in awhile on the forums.

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...
Most Valuable Participant ,
Sep 12, 2017

Copy link to clipboard

Copied

MikeGondek

Hope so CarlosCanto​ will be not angry about the changing.

Try this

#target Illustrator

// script.name = relinkAllSelected.jsx;

// script.description = relinks all selected placed images at once;

// script.required = select at least one linked image before running;

// script.parent = CarlosCanto // 7/12/11;

// script.elegant = false;

// https://forums.adobe.com/thread/2381744

// ---------------------------------------------------------------------------------

// changed: relink all selected placed items with ONE new file

// ---------------------------------------------------------------------------------

var idoc = app.activeDocument;

sel = idoc.selection;

if (sel.length>0)

    {

    var file = File.openDialog ("open file " + iplaced.file );

    for (i=0 ; i<sel.length ; i++ )

        {

            if (sel.typename == "PlacedItem")

                {

                    var iplaced = sel;

                    //var file = File.openDialog ("open file " + iplaced.file );

                    iplaced.file = file;

                }

            }

        }

    else

    {

    alert("select at least one placed item before running");

}

Select the placed images and run this snippet.

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...
Adobe Community Professional ,
Sep 12, 2017

Copy link to clipboard

Copied

Thank you so much. Got an error. I tried both .js & .jsx file extension.

Screen Shot 2017-09-12 at 4.19.57 PM.png

FYI: To me does not matter if I need to select all images, one, or none. Whatever is easiest and most reliable for future Illustrator updates. Would even be happy if I could do a do a find /change to the code. eg: "ButterfingerCrunch 01.psd" to "ButterfingerCrunch 02.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
Reply
Loading...
Most Valuable Participant ,
Sep 12, 2017

Copy link to clipboard

Copied

Oops

Moving a line before the variable was defined is never a good idea.

var file = File.openDialog ("open file " + iplaced.file );

should be

var file = File.openDialog ("open file ");

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...
Adobe Community Professional ,
Sep 12, 2017

Copy link to clipboard

Copied

That did it! Thank You!

Screen Shot 2017-09-12 at 5.45.34 PM.png

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...
Contributor ,
Nov 14, 2019

Copy link to clipboard

Copied

Good evening -

 

I'm running under Illustrator CC 23.1.1

And when I launch the script, well AI asks me to open a file (the new one), I click on "open"…

But after that nothing happen.

 

Any idea why?

Thank you

 

 

 

- Dimitri

 

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...
Adobe Community Professional ,
Nov 14, 2019

Copy link to clipboard

Copied

did you select your images on the artboard first?

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...
Contributor ,
Nov 15, 2019

Copy link to clipboard

Copied

Hey Carlos -

 

Yes, I do, otherwise I'd get the "alert" message…

Any idea?

 

 

- Dimitri

 

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...
Adobe Community Professional ,
Nov 15, 2019

Copy link to clipboard

Copied

your images are probably rasterItems (embedded) instead of placed, can you confirm?

if that's the case, there's another version of the script that deals with both types of images

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...
Contributor ,
Nov 15, 2019

Copy link to clipboard

Copied

Hello Carlos -

 

I double checked and they are not.

So they are NOT embedded.

 

 

- Dimitri

 

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...
Adobe Community Professional ,
Nov 18, 2019

Copy link to clipboard

Copied

Hi dimitri, can you share a sample file to play with?

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...
Contributor ,
Nov 22, 2019

Copy link to clipboard

Copied

Hello Carlos -

 

Please, find here a rogh AI file with a couple of pictures —>   https://file.io/IxePDv

I run under Mac OS X Mojave 10.14.6 + AI CC2019

 

Big thanks for your lihghts and time.

 

 

 

- Dimitri

 

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...