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

Re-link lots of images? Indesign CS3

New Here ,
Apr 17, 2008 Apr 17, 2008
Hi - I posted this in the indesign forum and it was suggested to look here. I've had a quick look for a solution but thought I'd post aswell.

"Because I've resaved a load of jpegs to psds the links are now broken.

Is it possible to relink them all without doing each one manually?

The update link option is greyed out. All the psds are in the same folder. "

Thanks again
TOPICS
Scripting
15.0K
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
Community Beginner ,
Apr 17, 2008 Apr 17, 2008
for MAC or for PC ??
(I don't see your post on adobe.indesign.windows forum)

robin

--
www.adobescripts.com
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 ,
Apr 17, 2008 Apr 17, 2008
Hi

For MAC.

Thanks
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 ,
Apr 17, 2008 Apr 17, 2008
Hi jamesho,
I haven't tested it, but think it's should be something like this:
//-------------------------------
var myImages = app.activeDocument.allGraphics;

for (i = myImages.length-1; i >= 0 ; i--) {
var myImage = myImages.itemLink;
var myNewName = myImage.filePath.replace(/\.jpg$/i, "") + ".psd";
var myNewLink = new File (myNewName);
if (myNewLink.exists) {
myImage.relink (myNewLink);
myImage.update();
}
}

//-------------------------------
I assume JPG and PSD files are in the same folder.
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 ,
Apr 17, 2008 Apr 17, 2008
Hi Kasyan,

Thanks for your reply. To be honest I don't know anything about scripts and am not sure what to do with the info you've posted. Can you help?

The other thing is I've trashed all the JPG thinking I didn't need them anymore.

James
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 ,
Apr 17, 2008 Apr 17, 2008
1 Copy the code I posted
2. Start up ExtendScript Toolkit 2 (Applications > Utilities > Adobe Utilities > ExtendScript Toolkit 2 folder)
3. Create a new file
4. Paste the code
5. Save the Script into Applications > Adobe InDesign CS3 > Scripts > Scripts Panel folder, or alternatively into your home directory > Library > Preferences > Adobe InDesign > Version 5.0 > Scripts > Scripts Panel folder

Your PSD files should be in the same folder (have the same path) as where the JPG files used to be.
Open your document and double click the script in the Scripts Panel (Window > Automation > Scripts.

I can send you the script, if you e-mail me at kasyan@business.ua

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
Guest
May 05, 2008 May 05, 2008
Can you tell me if this would work or could be adjusted to work if the file names were changed rather than just the suffix.

I've placed an Illustrator image in IDCS3 many times but since then I've renamed the file and now ID is looking for the original. The only way I could update them all was to relink each one individually. Is there a way of relinking them all collectively?

I'm sure the above script would do the job but it may need some expert tinkering before hand.

David
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 ,
May 05, 2008 May 05, 2008
>Is there a way of relinking them all collectively?

After you pressed Relink button or chose Relink menu command in Links Panel, you should set Relink All Instances of “YourFileName.ai” check box.

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 ,
May 29, 2008 May 29, 2008
how could this be modified so that...
1. instead of a changed filename it looks for the same name in a NEW folder.
2. possibly ignore the extensions and link to a file with the same base filename.

I had one that worked great in CS2 but can't find it.
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 ,
May 30, 2008 May 30, 2008
Hi Kevin,
I made this script in a rough-and-ready fashion – don’t have time to test it. Hope it does what you want. If not, let me know.
myNewFolder variable is set to “NewLinks” folder is in the same folder where your active InDesign document has been saved, but you can type any path you need, or I can make a dialog to choose a folder with new links.

Kasyan
//---------------------------------------------------
var myDoc = app.activeDocument;

// NewLinks folder is in the same folder where your active InDesign document has been saved
var myNewFolder = myDoc.filePath + "/NewLinks/";
// List all possible file extension in this array
var myExtentions = [".psd", ".tif", ".jpg", ".eps", ".pdf"];
var myImages = app.activeDocument.allGraphics;
for (i = myImages.length-1; i >= 0 ; i--) {
var myImage = myImages.itemLink;
var myOldPath = myImage.filePath;
var myNewPath = myNewFolder + myImage.name;
if (myOldPath != myNewPath) {
var myResult = myRelink(myNewPath);
if (myResult == false) {
for (var k = 0; k < myExtentions.length; k++) {
try {
myNewPath = myNewPath.slice(0,-4) + myExtentions;
myRelink(myNewPath);
}
catch (myError){}
}
}
}
}

function myRelink(myNewPath) {
var myNewLink = new File (myNewPath);
if (myNewLink.exists) {
myImage.relink (myNewLink);
myImage.update();
return true;
}
return false;
}
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 ,
Jun 03, 2008 Jun 03, 2008
Here is a new and improved version of the above script. May be it will come in handy to somebody.
//-------------------------------------------------
if(app.documents.length != 0){

var myFolder = Folder.selectDialog ("Choose a folder with new links");
if(myFolder != null){
var myCounter = 0;
main();
}
}
else {
alert("Please open a document and try again.");
}
function main(){
var myDoc = app.activeDocument;
var myNewFolder = myFolder.fsName + "/";
// List all possible file extension in this array
var myExtentions = [".psd", ".tif", ".jpg", ".eps", ".pdf", ".indd"];
var myImages = app.activeDocument.allGraphics;
for (i = myImages.length-1; i >= 0 ; i--) {
var myImage = myImages.itemLink;
var myOldPath = myImage.filePath;
var myNewPath = myNewFolder + myImage.name;
if (Folder.fs == "Macintosh") {
myOldPath = "/" + myOldPath.replace(/:/g, "/");
}
else if (Folder.fs == "Windows") {
myNewPath = myNewPath.replace(/\//g, "\\");
}
if (myOldPath != myNewPath) {
var myResult = myRelink(myNewPath, myImage);
if (myResult == false) {
for (var k = 0; k < myExtentions.length; k++) {
try {
myNewPath = myNewPath.slice(0,-4) + myExtentions;
myRelink(myNewPath, myImage);
}
catch (myError){}
}
}
}
}
if (myCounter > 0) {
alert(myCounter + " files has been relinked.");
}
else {
alert("Nothing has been relinked.");
}
}
function myRelink(myNewPath, myImage) {
var myNewLink = new File (myNewPath);
if (myNewLink.exists) {
myImage.relink (myNewLink);
myImage.update();
myCounter++;
return true;
}
return false;
}
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 ,
Jun 05, 2008 Jun 05, 2008
Kasyan!!

Dude you saved my ass!! I had 1200 PDFs and EPS all needing relink location changes!!!

Thank you!
Simon
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 ,
Jun 11, 2008 Jun 11, 2008
Hi,

Is there any way this script could be edited to look in subfolders of the folder you choose from the dialogue box? This would solve a problem that has been bugging me for a long time.

Antóin.
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 ,
Jun 11, 2008 Jun 11, 2008
Hi Antóin,

I'll try to do it a little bit later today.

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 ,
Jun 11, 2008 Jun 11, 2008
Fantastic.

Thanks,

Antóin.
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 ,
Jun 11, 2008 Jun 11, 2008
Antóin,

You can download the script from here:
http://www.businessweekly.h.com.ua/relink.html
or just copy and paste from this post.

I hope it will work for you. If you find any bugs let me know.

Kasyan
//---------------------------------------------
This script relinks old links with new ones in a folder you choose, including subfolders.
At first, it looks for the new link that has the same name as the old one in the selected folder and if it's found, relinks it.
If the link with the exact name is not found, the sript tries to find a file with the same base name but a different extension (".psd", ".tif", ".jpg", ".eps", ".pdf", ".indd").
If the script doesn't find the new link in the chosen folder, it searches it in all subfolders.
//---------------------------------------------

if(app.documents.length != 0){
var myDoc = app.activeDocument;
var myFolder = Folder.selectDialog ("Choose a folder with new links");
if(myFolder != null){
var myCounter = 0;
var mySubFolders = new Array;
getSubFolders(myFolder);
var myNewFolder = myFolder.absoluteURI + "/";
main(myNewFolder);
if (mySubFolders.length > 0) {
for (var s = 0; s < mySubFolders.length; s++) {
myNewFolder = mySubFolders + "/";
main(myNewFolder);
}
}
if (myCounter == 1) {
alert("One file has been relinked.");
}
else if (myCounter > 1) {
alert(myCounter + " files have been relinked.");
}
else {
alert("Nothing has been relinked.");
}
}
}
else {
alert("Please open a document and try again.");
}
function main(myNewFolder){
// List all possible file extension in this array
var myExtentions = [".psd", ".tif", ".jpg", ".eps", ".pdf", ".indd"];
var myImages = app.activeDocument.allGraphics;
var myCurrFolder = Folder (myNewFolder);
var myCurrFolderName = "Folder " + myCurrFolder.displayName;
var stop = myImages.length;
var w = new Window ( 'window', myCurrFolderName );
var pb = w.add ('progressbar', [12, 12, 350, 24], 0, stop);
var txt = w.add('statictext');
txt.bounds = [0, 0, 340, 20];
txt.alignment = "left";
w.show();
var a = 1;
for (i = myImages.length-1; i >= 0 ; i--) {
var b = (myImages.length - myImages.length) + a;
pb.value = b;
a++;
var myText = String("Relinking file " + myImages.itemLink.name);
txt.text = myText;
var myImage = myImages.itemLink;
var myImageFile = new File (myImage.filePath);
var myOldPath = myImageFile.toString();
var myNewPath = myNewFolder + myImage.name;
if (myOldPath != myNewPath) {
var myResult = myRelink(myNewPath, myImage);
if (myResult == false) {
for (var k = 0; k < myExtentions.length; k++) {
try {
myNewPath = myNewPath.slice(0,-4) + myExtentions;
myRelink(myNewPath, myImage);
}
catch (myError){}
}
}
}
}
w.close();
}
function myRelink(myNewPath, myImage) {
var myNewLink = new File (myNewPath);
if (myNewLink.exists) {
myImage.relink (myNewLink);
myImage.update();
myCounter++;
return true;
}
return false;
}
function getSubFolders(theFolder) {
var myFileList = theFolder.getFiles();
for (var i = 0; i < myFileList.length; i++) {
var myFile = myFileList;
if (myFile instanceof Folder){
mySubFolders.push(myFile.absoluteURI);
getSubFolders(myFile);
}
}
return mySubFolders;
}
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 ,
Jun 12, 2008 Jun 12, 2008
Hi Kasyan,

Thanks so much for that. It takes a while to work but it works a treat. Saves me a whole lot of time relinking images for documents as I save all my images in one folder and have subfolders within that. It was so annoying having to search through linking images everytime.

Thanks again,

Antóin.
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 ,
Aug 06, 2008 Aug 06, 2008
Hi all,

Today I received an e-mail from a guy who had a problem with the script I had posted. The problem was that he had CS2 but the script was written for CS3. I removed the progress bar from the script so now it works in CS2, and posted both versions here:
http://www.businessweekly.h.com.ua/relink.html
(In case somebody else is interested).

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
Participant ,
Aug 11, 2008 Aug 11, 2008
Hi Kasyan,

I am constantly amazed at how generous you and the other scripters on this forum are...

So many threads go somethiing like this:
Poster1: "I need to do something but I have no idea how to...and I haven't really tried to learn..."
Scripter: "Here's a script that should do what you need"
Poster1: "Wow, that's great. But can you also make it do....."
Scripter: "No worries, here's a revised version"
Poster2: "Could you also make it do...."
Scripter: "Yep, no worries, here's a more complicated version."

You contributors are all wonderfully brilliant people. Thanks so much,
d.
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 ,
Aug 13, 2008 Aug 13, 2008
This is so helpful! Is there any way that this script could be applied to an entire book rather than just one document?

Thanks so much!
Elizabeth
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 ,
Aug 14, 2008 Aug 14, 2008
Hi Dwayne Smith and Elizabeth,

Its so nice to read such kind words. For me, its important to have such a feedback, because if I know that people use my script I have a strong incentive to improve it. Im working on a new version: my goal is to make the script stop searching for the further folders, if the image has been successfully linked. The idea was given by Bharathi Raja on this thread http://www.adobeforums.com/webx/.59b5c193/11

>Is there any way that this script could be applied to an entire book rather than just one document?

Im sure its possible; Ill give it a try when I have a little spare time. And right now I have a question for you: the script needs to know which book to work with. Do you usually keep one or several book(s) open in InDesign? In the first case, its easier to do; in the second Ill have to write a dialog box for the user to choose a book.

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 ,
Aug 14, 2008 Aug 14, 2008
Kasyan, you totally rock! I used your script and it worked great. Thank you for saving my wrists from carpal tunnel!!
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 ,
Aug 21, 2008 Aug 21, 2008
Hi all,

Ive posted a new, totally remade and much better (I hope) version of the script for updating path names in links.
http://www.businessweekly.h.com.ua/relink.html
The previous version 8.8 has a problem with processing subfolders, as pointed out here http://www.adobeforums.com/webx?128@@.59b5c193 (post 11) by Bharathi Raja.
Now, if the script finds and successfully relinks a link, it stops searching and replacing this link in subsequent subfolders. It now also works both in InDesign CS2 and CS3.

Id like to make a little public opinion poll:
Does anybody need the script to work with other file formats (e.g. linked InCopy files)?
Im thinking of adding a window at start, for user to have a choice to select where script should work e.g. Active document/All open documents/Select a book (from listbox). What do you think about it?
Now concerning embedded links: at present, if the script finds a link with same base name it unembeds and relinks it to this link. Does anybody need more control for embedded links? (e.g. a checkbox to relink/dont relink embedded links)

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
Valorous Hero ,
Aug 22, 2008 Aug 22, 2008
I found a bug in the script that I posted yesterday: not all file extensions were processed by the script properly. Now Ive corrected the mistake and posted a new version 10.1.
http://www.businessweekly.h.com.ua/relink.html
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
Community Expert ,
Aug 25, 2008 Aug 25, 2008
Great Script.
I have to concur with Dwayne, some of the posters in the Scripting-fora are remarkably generous with their expertise; thanks, Kasyan.

One peculiarity: at least on my station I get »One file has been relinked.« even if a lot more files have actually been relinked.

Regarding Your poll:
 The file-formats You implemented so far suffice for my needs.
 The opportunity to apply to all open documents seems nice though not essential.
 No opinion  as I usually dont embed images in Indesign-documents anyway.
One feature I myself (due to the way we organize images around the company I work at) would find useful would be the adding/recognition of additional »suffixes«; depending on print-conditions we often have numerous versions of an image that have been separated utilizing different profiles which are signified by an added »_coa«, »_web« etc. at the end of the filename. But Im not sure if that way of handling images is widespread enough to merit consideration.
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