0
[CS2][JS]Relink images for web and print
New Here
,
/t5/indesign-discussions/cs2-js-relink-images-for-web-and-print/td-p/1123061
Jan 06, 2009
Jan 06, 2009
Copy link to clipboard
Copied
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.
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Contributor
,
/t5/indesign-discussions/cs2-js-relink-images-for-web-and-print/m-p/1123062#M336533
Jan 06, 2009
Jan 06, 2009
Copy link to clipboard
Copied
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
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_charles_darwin_
AUTHOR
New Here
,
/t5/indesign-discussions/cs2-js-relink-images-for-web-and-print/m-p/1123063#M336534
Jan 06, 2009
Jan 06, 2009
Copy link to clipboard
Copied
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
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
People's Champ
,
/t5/indesign-discussions/cs2-js-relink-images-for-web-and-print/m-p/1123064#M336536
Jan 07, 2009
Jan 07, 2009
Copy link to clipboard
Copied
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){}
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
People's Champ
,
/t5/indesign-discussions/cs2-js-relink-images-for-web-and-print/m-p/1123065#M336538
Jan 07, 2009
Jan 07, 2009
Copy link to clipboard
Copied
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
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Contributor
,
/t5/indesign-discussions/cs2-js-relink-images-for-web-and-print/m-p/1123066#M336539
Jan 07, 2009
Jan 07, 2009
Copy link to clipboard
Copied
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'.
Then you will have to change the old part of the name with a new part:
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
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Contributor
,
/t5/indesign-discussions/cs2-js-relink-images-for-web-and-print/m-p/1123067#M336541
Jan 07, 2009
Jan 07, 2009
Copy link to clipboard
Copied
Ah, Loic has posted the completion while I have been thinking about some details. ;-)
Martin
Martin
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
People's Champ
,
/t5/indesign-discussions/cs2-js-relink-images-for-web-and-print/m-p/1123068#M336543
Jan 07, 2009
Jan 07, 2009
Copy link to clipboard
Copied
Hi Martin,
It doesn't prevent from posting smarter ways ;-)
Loic
It doesn't prevent from posting smarter ways ;-)
Loic
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_charles_darwin_
AUTHOR
New Here
,
/t5/indesign-discussions/cs2-js-relink-images-for-web-and-print/m-p/1123069#M336545
Jan 07, 2009
Jan 07, 2009
Copy link to clipboard
Copied
Hi Loic,
The script works perfectly. One more thing, can you make it loop so it does on all images? thanks.
Charles
The script works perfectly. One more thing, can you make it loop so it does on all images? thanks.
Charles
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_charles_darwin_
AUTHOR
New Here
,
/t5/indesign-discussions/cs2-js-relink-images-for-web-and-print/m-p/1123070#M336546
Jan 07, 2009
Jan 07, 2009
Copy link to clipboard
Copied
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();
}
}
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();
}
}
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_charles_darwin_
AUTHOR
New Here
,
/t5/indesign-discussions/cs2-js-relink-images-for-web-and-print/m-p/1123071#M336548
Jan 07, 2009
Jan 07, 2009
Copy link to clipboard
Copied
Ah thank God there is a place like this one. Imagine life without adobeforums... sigh... thanks guys.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Valorous Hero
,
/t5/indesign-discussions/cs2-js-relink-images-for-web-and-print/m-p/1123072#M336550
Jan 07, 2009
Jan 07, 2009
Copy link to clipboard
Copied
Hi Charles,
Try this:
Kasyan
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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
_charles_darwin_
AUTHOR
New Here
,
LATEST
/t5/indesign-discussions/cs2-js-relink-images-for-web-and-print/m-p/1123073#M336551
Jan 07, 2009
Jan 07, 2009
Copy link to clipboard
Copied
Hi Kasyan,
Thanks for the effort you've been very helpful, thanks.
Charles
Thanks for the effort you've been very helpful, thanks.
Charles
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

