Copy link to clipboard
Copied
Hi All,
i have this problem:
all images were in folder: T:\RacPnt\2020
es: T:\RacPnt\2020\Big\Logo.png
And now, path is changed to:
T:\RaccoltaPunti\2020
es: T:\RaccoltaPunti\2020\Big\Logo.png
Is it possible to change a part of link for all resource at once time?
Thanks.
I quickly put a script that should do the trick, what it needs is the base path fragment that needs to be changed and the path that is to be used. These two variables are defined at the top of the script. So for you the script would be as follows
var changeWhat = new RegExp("^T:\\RacPnt")
var changeTo = "T:\\RaccoltaPunti"
for(var i = 0; i < app.activeDocument.links.length; i++)
{
var ln = new File(app.activeDocument.links[i].filePath).fsName
var a = ln.replace(changeWhat, changeTo)
try{
...
Copy link to clipboard
Copied
Select a link in the links panel to relink, in the dialog that appears select the option "Search for missing links in this folder"
For details refer the following link, refer the section "restore missing links"
https://helpx.adobe.com/indesign/using/graphics-links.html
-Manan
Copy link to clipboard
Copied
Hi Manan, thanks for help.
The problem is what has changed is only the beginning of the link.
In my example:
Before: T:\RacPnt\2020\Big\Logo.png
After: T:\RaccoltaPunti\2020\Big\Logo.png
But obviously i have many under folders and many links (more than 100).
So for the next resource is for exaple:
Before: T:\RacPnt\2020\Little\Logo.png
After: T:\RaccoltaPunti\2020\Little\Logo.png
Following your method, i have to repeat this process many times, one for each subfolder.
I'll get crazy.
I ask if it is possible to change the start of the route for all connections.
Thanks.
Copy link to clipboard
Copied
what are you trying to accomplish?
Do you want to relink all images at once from the new folder?
If yes, select any missing link in your link panel > relink > select that image and tick bellow "Search for missing link in this folder"
Copy link to clipboard
Copied
Hi Vladan, thanks for help.
The problem is what has changed is only the beginning of the link.
In my example:
Before: T:\RacPnt\2020\Big\Logo.png
After: T:\RaccoltaPunti\2020\Big\Logo.png
But obviously i have many under folders and many links (more than 100).
So for the next resource is for example:
Before: T:\RacPnt\2020\Little\Logo.png
After: T:\RaccoltaPunti\2020\Little\Logo.png
Following your method, i have to repeat this process many times, one for each subfolder.
I'll get crazy.
I ask if it is possible to change the start of the route for all connections.
Thanks.
Copy link to clipboard
Copied
Ok that would need a script then, i think i have seen one such script by Kasyan. I will post if i am able to locate it
-Manan
Copy link to clipboard
Copied
I agree with you, i think i need a script.
If you find a script i'll use.
Thank you really much.
Copy link to clipboard
Copied
on mac:
select all your folders > right click > rename "number of folders" elements > change text
Copy link to clipboard
Copied
This i did.
Now i have to inform Indesign of the new link.
Copy link to clipboard
Copied
I quickly put a script that should do the trick, what it needs is the base path fragment that needs to be changed and the path that is to be used. These two variables are defined at the top of the script. So for you the script would be as follows
var changeWhat = new RegExp("^T:\\RacPnt")
var changeTo = "T:\\RaccoltaPunti"
for(var i = 0; i < app.activeDocument.links.length; i++)
{
var ln = new File(app.activeDocument.links[i].filePath).fsName
var a = ln.replace(changeWhat, changeTo)
try{
if(ln != a)
app.activeDocument.links[i].relink(new File(a))
}catch(e)
{alert("Could not relink to " + a)}
}
You can change the variables changeTo and changeWhat as per your need, i have made changes as per your example
-Manan
Copy link to clipboard
Copied
Did you tried this script? For you it works?
I tried but didn't work for me.
I correctly inserted the script oon the folder (extension? i set ".jsx").
I run it but nothing happen.
Obviously i changed the path as your indication.
Copy link to clipboard
Copied
Tested it on my MAC did work. Can you share a video showing the script you finally run, the original image location, the new image location. Maybe i might observe the issue, if this does not work i will test it on a Win machine
-Manan
Copy link to clipboard
Copied
I think is a problem of windows.
I wrote some alerts to check the script:
var ln = new File(app.activeDocument.links[i].filePath).fsName
var a = ln.replace(changeWhat, changeTo)
alert(changeWhat)
alert(changeTo)
alert(a)
Alert with "changeTo" and "a" variable are correct; but variable "changeWhat" not.
Alert wrote this:
/^T:\RacPnt/
I think there are 3 characters in excess: the first 2 and the last.
Copy link to clipboard
Copied
No the characters are fine, it denotes the regex object
-Manan
Copy link to clipboard
Copied
Also does alert(a) print the new location of the image or not? Do you get any alerts saying it could not relink?
Can you share the video that i asked that will help in debugging
-Manan
Copy link to clipboard
Copied
Try changing the variables to the following
var changeWhat = new RegExp("^T:\\\\RacPnt")
var changeTo = "T:\\RaccoltaPunti"
-Manan
Copy link to clipboard
Copied
I solved it by modifying the first variable:
From: var changeWhat = new RegExp("^T:\\RacPnt\xxx")
To: var changeTo = "T:\\RaccoltaPunti\xxx"
My solution is different because there isn't the regular expression, (but those words are never repeated in the path).
Now it works.
Thank you!!!