🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
13 messages
13 total messages Started by charles_darwin Wed, 07 Jan 2009 05:23
[CS][JS]Relink images for web and print
#2233
Author: charles_darwin
Date: Wed, 07 Jan 2009 05:23
2 lines
878 bytes
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.
Re: [CS2][JS]Relink images for web and print
#2235
Author: Martin Fischer
Date: Wed, 07 Jan 2009 06:07
7 lines
1069 bytes
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
Re: [CS2][JS]Relink images for web and print
#2237
Author: charles_darwin
Date: Wed, 07 Jan 2009 07:49
10 lines
1049 bytes
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
Re: [CS2][JS]Relink images for web and print
#2238
Author: loic_aigon
Date: Wed, 07 Jan 2009 08:24
13 lines
977 bytes
var doc = app.activeDocument;
var lk = doc.links;
try{
for(i=0; i<lk.length;i++) { 	lkname =lk[i].name; 	if(lkname.indexOf("_print.eps")>=0)
	{
		var lkname0 = lkname.split("_print.eps")[0];
		lkfolder = File(lk[i].filePath).parent;
		lk[i].relink(File(lkfolder+"/"+lkname0+"_web.eps"));
		lk[i].update();
	}
}
}
catch(e){}
Re: [CS2][JS]Relink images for web and print
#2239
Author: loic_aigon
Date: Wed, 07 Jan 2009 08:26
4 lines
744 bytes
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
Re: [CS2][JS]Relink images for web and print
#2240
Author: Martin Fischer
Date: Wed, 07 Jan 2009 08:38
24 lines
1164 bytes
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 contains '_web.eps'.

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


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

 
var newName = myLinks[i].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
Re: [CS2][JS]Relink images for web and print
#2241
Author: Martin Fischer
Date: Wed, 07 Jan 2009 08:42
3 lines
604 bytes
Ah, Loic has posted the completion while I have been thinking about some details. ;-)

Martin
Re: [CS2][JS]Relink images for web and print
#2242
Author: loic_aigon
Date: Wed, 07 Jan 2009 09:05
3 lines
756 bytes
Hi Martin,
It doesn't prevent from posting smarter ways ;-)
Loic
Re: [CS2][JS]Relink images for web and print
#2243
Author: charles_darwin
Date: Wed, 07 Jan 2009 09:15
3 lines
739 bytes
Hi Loic,
The script works perfectly. One more thing, can you make it loop so it does on all images? thanks.
Charles
Re: [CS2][JS]Relink images for web and print
#2046
Author: charles_darwin
Date: Wed, 07 Jan 2009 09:53
13 lines
994 bytes
Hi loic/Martin
This is Kasyan's version:

var myImages = app.activeDocument.allGraphics;
for (i = myImages.length-1; i >= 0 ; i--) {
   var myImage = myImages[i].itemLink;
   var myNewName = myImage.filePath.replace(/\_web.eps$/i, "_print.eps");
   var myNewLink = new File (myNewName);
      if (myNewLink.exists) {
         myImage.relink (myNewLink);
         myImage.update();
      }
}
Re: [CS2][JS]Relink images for web and print
#2047
Author: charles_darwin
Date: Wed, 07 Jan 2009 09:54
1 lines
767 bytes
Ah thank God there is a place like this one. Imagine life without adobeforums... sigh... thanks guys.
Re: [CS2][JS]Relink images for web and print
#2059
Author: Kasyan Servetsky
Date: Wed, 07 Jan 2009 17:11
22 lines
1181 bytes
Hi Charles,
Try this:


 
var myImages = app.activeDocument.allGraphics;
for (i = myImages.length-1; i >= 0 ; i--) {
   var myImage = myImages[i].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
Re: [CS2][JS]Relink images for web and print
#2077
Author: charles_darwin
Date: Thu, 08 Jan 2009 04:17
5 lines
718 bytes
Hi Kasyan,

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

Charles
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads