//Script will update the document's links based upon its current location.
var doc = app.activeDocument;
updateLinksRelativeToDocument(doc);
function updateLinksRelativeToDocument(doc){
var docLinksFolder = new Folder(doc.filePath + '/Links');
var docLinksFolderFiles = docLinksFolder.getFiles();
var docLinks = doc.links;
for(l = 0; l < docLinks.length; l++){
var link = docLinks[l];
var newLink = findLinkRelativeToCurrentDocumentLocation(docLinksFolderFiles, link);
if(newLink){
link.relink(newLink);
$.writeln('successfully relinked');
}
}
}
function findLinkRelativeToCurrentDocumentLocation(linksArray, link){
var linkFile = link.name;
for(var i = 0; i < linksArray.length; i++){
var linkToSearch = linksArray[i];
if(linkToSearch.toString().search(linkFile) > -1){
var x = 0;
return linkToSearch;
}
}
return null;
}
//Script will update the document's links based upon its current location.
var doc = app.activeDocument;
updateLinksRelativeToDocument(doc);
function updateLinksRelativeToDocument(doc){
var docLinksFolder = new Folder(doc.filePath + '/Links');
var docLinksFolderFiles = docLinksFolder.getFiles();
var docLinks = doc.links;
for(l = 0; l < docLinks.length; l++){
var link = docLinks[l];
var newLink = findLinkRelativeToCurrentDocumentLocation(docLinksFolderFiles, link);
if(newLink){
link.relink(newLink);
$.writeln('successfully relinked');
}
}
}
function findLinkRelativeToCurrentDocumentLocation(linksArray, link){
var linkFile = link.name;
for(var i = 0; i < linksArray.length; i++){
var linkToSearch = linksArray[i];
if(linkToSearch.toString().search(linkFile) > -1){
var x = 0;
return linkToSearch;
}
}
return null;
}