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

[CS2][JS]Relink images for web and print

New Here ,
Jan 06, 2009 Jan 06, 2009
Scripters i need help with this one:
We have 2 sets of images .tif and .eps. i have no problem with the .tif but my problem is the eps images. There are 2 versions of .eps: "_print" and "_web". Is there anyway a script can relink (e.g.) image01_print.eps with image01_web.eps or vice versa automatically? All images are in same folder.
TOPICS
Scripting
762
Translate
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
Contributor ,
Jan 06, 2009 Jan 06, 2009
Hi Charles,

you could use the script in http://www.hilfdirselbst.ch/foren/Bild-Verkn%FCpfungen_erneut_verkn%FCpfen_P210839.html#210839 as a starting point.

You will find some more examples while searching for the keyword 'relink': http://www.hilfdirselbst.ch/foren/gforum.cgi?do=search_results&search_forum=forum_4&search_string=relink&search_type=AND&search_fields=b&search_time=&search_user_username=&sb=post_time&mh=50

Martin Fischer
Translate
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
New Here ,
Jan 06, 2009 Jan 06, 2009
Thanks Martin,

is it in German or Russian? i don't understand a word. but i do understand "some" part of the scripts. sorry but i don't know how to modify the script to make it this way:

- Indesign look for the images in .eps (ignore other formats),
- if found - look for the path
- search the whole folder for the words "_web.eps" or "_print.eps"
- if found, change "image01_web.eps" to "image01_print.eps" or vice versa.

Charles
Translate
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
People's Champ ,
Jan 07, 2009 Jan 07, 2009
var doc = app.activeDocument;<br />var lk = doc.links;<br />try{<br />for(i=0; i<lk.length;i++)<br />{<br /> lkname =lk.name;<br /> if(lkname.indexOf("_print.eps")>=0)<br /> {<br /> var lkname0 = lkname.split("_print.eps")[0];<br /> lkfolder = File(lk.filePath).parent;<br /> lk.relink(File(lkfolder+"/"+lkname0+"_web.eps"));<br /> lk.update();<br /> }<br />}<br />}<br />catch(e){}
Translate
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
People's Champ ,
Jan 07, 2009 Jan 07, 2009
BTW experts,
What's the point of EPSs.count() and how to use it ? I tried to for this script and couldn't take advantage on it.

Loic
Translate
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
Contributor ,
Jan 07, 2009 Jan 07, 2009
Hi Charles,

it's in German.
And the comments are in german language too.
But the code of the scripts is international.

You will have to find out whether the name of a link is containing '_web.eps'.

if (myLinks.name.match('_web.eps') != null)
...

Then you will have to change the old part of the name with a new part:

var newName = myLinks.name.replace('_web.eps', '_print.eps');

And now you will have to try to relink the link with a file with the new name.

The scripts above should tell you the way to do this.

Martin
Translate
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
Contributor ,
Jan 07, 2009 Jan 07, 2009
Ah, Loic has posted the completion while I have been thinking about some details. ;-)

Martin
Translate
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
People's Champ ,
Jan 07, 2009 Jan 07, 2009
Hi Martin,
It doesn't prevent from posting smarter ways ;-)
Loic
Translate
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
New Here ,
Jan 07, 2009 Jan 07, 2009
Hi Loic,
The script works perfectly. One more thing, can you make it loop so it does on all images? thanks.
Charles
Translate
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
New Here ,
Jan 07, 2009 Jan 07, 2009
Hi loic/Martin
This is Kasyan's version:

var myImages = app.activeDocument.allGraphics;
for (i = myImages.length-1; i >= 0 ; i--) {
var myImage = myImages.itemLink;
var myNewName = myImage.filePath.replace(/\_web.eps$/i, "_print.eps");
var myNewLink = new File (myNewName);
if (myNewLink.exists) {
myImage.relink (myNewLink);
myImage.update();
}
}
Translate
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
New Here ,
Jan 07, 2009 Jan 07, 2009
Ah thank God there is a place like this one. Imagine life without adobeforums... sigh... thanks guys.
Translate
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
Valorous Hero ,
Jan 07, 2009 Jan 07, 2009
Hi Charles,
Try this:


var myImages = app.activeDocument.allGraphics;
for (i = myImages.length-1; i >= 0 ; i--) {
var myImage = myImages.itemLink;
if (myImage.filePath.match("_web") != null) {
var myNewName = myImage.filePath.replace(/_web/, "_print");
}
else if (myImage.filePath.match("_print") != null) {
var myNewName = myImage.filePath.replace(/_print/, "_web");
}
var myNewLink = new File (myNewName);
if (myNewLink.exists) {
myImage.relink (myNewLink);
myImage.update();
}
}

Kasyan
Translate
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
New Here ,
Jan 07, 2009 Jan 07, 2009
LATEST
Hi Kasyan,

Thanks for the effort you've been very helpful, thanks.

Charles
Translate
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