Copy link to clipboard
Copied
Could you show me how to write a javascript that can do the "Copy Link(s) to…"? It would be time consuming to do it manually. Thanks in advance.
Hi,
copyLink(File) is a link's method.
However "How to write javascript" mostly depends on assumings.
Below code assumes:
Every valid link from active document is copied to destFolder keeping current file name.
...var
mDoc = app.activeDocument,
mLinks = mDoc.links.everyItem().getElements(),
destFolder = "~/Desktop/copiedLinks/",
currLinkFName, currFile,
len = mLinks.length;
if ( !Folder(destFolder).create() ) exit();
while (len-->0) {
currLinkFName = mLinks[len].filePath;
currFile = F
Copy link to clipboard
Copied
Hi,
copyLink(File) is a link's method.
However "How to write javascript" mostly depends on assumings.
Below code assumes:
Every valid link from active document is copied to destFolder keeping current file name.
var
mDoc = app.activeDocument,
mLinks = mDoc.links.everyItem().getElements(),
destFolder = "~/Desktop/copiedLinks/",
currLinkFName, currFile,
len = mLinks.length;
if ( !Folder(destFolder).create() ) exit();
while (len-->0) {
currLinkFName = mLinks[len].filePath;
currFile = File( destFolder + File(currLinkFName).name );
if (File(currLinkFName).exists)
mLinks[len].copyLink(currFile);
}
Jarek
Copy link to clipboard
Copied
Jump_Over,
Thanks, I will give it a try.
Copy link to clipboard
Copied
Wow, it worked. You are awesome. I have been trying to figure that out for weeks. Now, I have to figure it out how to replace the deskFolder with the user input.
Copy link to clipboard
Copied
Hi,
1. Change a "correct" answer to mine, pls
2. In case of user input you can modify the line:
destFolder = Folder.selectDialog("Show me a target folder") + "/";
Is it helpful
Jarek
Copy link to clipboard
Copied
Jarek,
Yesss, I should have gone to this forum a long time ago. I am running to a problem. I have several identical links in my Indesign file, when I run the script, Indesign stopped and said "the link already exists (because it can not "save" over the existing one in the same folder). Is there a way I can bypass this. Something like
if (currFile.exists)
// bypass this command
Sorry, I am notice to Javascript. I am so excited to learn Javascript. Thanks for helping.
I am an expert in Indesign (non-script) of course, please ask me if you had any question in that area.
Phong
Copy link to clipboard
Copied
Hi,
Right, It can result with error. To bypass modify this line:
if ( !currFile.exists && File(currLinkFName).exists )
Jarek
Find more inspiration, events, and resources on the new Adobe Community
Explore Now