Renaming links for already-placed image files

New Here ,
Dec 14, 2021 Dec 14, 2021

Copy link to clipboard

Copied

Hi, 

 

We're hoping to rename a large number of image files that have already been placed in an InDesign document, as we're making some changes to a structured, chapter-by-chapter naming system we have for images. Is there a way to rename and relink these files at the same time from within InDesign, without having to relink the files afterwards by hand? 

 

There is a method described helpfully in this externally-posted guide, but it's unfortunately become outdated and unusable, as it was posted in 2007. 

 

Thanks for your help. For reference, we use Mac for our OS. 

TOPICS
Feature request , How to , Scripting

Views

117

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Dec 14, 2021 Dec 14, 2021

Copy link to clipboard

Copied

Hi @dncolburn, this is how I do it. I wrote a script that just does a find/replace within the links file paths, so the idea is that the new changed file path lines up with the files you want it to. Let me know if it doesn't make sense.

- Mark

/*
    Relinker
    for Adobe Indesign 2022
    by m1b

    Use this when your file system has changed and current links are broken.
    Set `replaceThis` and `withThis` to re-align the file paths.
*/

var replaceThis = "old-part/of/link/path", // use regex here if necessary, eg. /\d+/
    withThis = "new-part/of link path";


function main() {
    var _links = app.activeDocument.links;

    for (var i = 0; i < _links.length; i++) {

        // comment this out if you want to relink all links
        if (_links[i].status !== LinkStatus.LINK_MISSING) continue;

        // new file by replacing text within file path
        var newLinkedFile = File(_links[i].filePath.replace(replaceThis, withThis));

        // if file exists at the new file path, relink
        if (newLinkedFile.exists)
            _links[i].relink(newLinkedFile);
    }

}

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Relinker");

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Dec 15, 2021 Dec 15, 2021

Copy link to clipboard

Copied

A bit more info: since you are using Mac, the file paths use colons between folders, eg. "MacintoshHD:Users:mark:Desktop:myLinkedFile.pdf". You can see this in the Links panel. You can get a copy of it by selecting a link in the Links panel, going to the fly-out panel menu and choosing "Copy Info > Platform Style Path".

Likes

Translate

Translate

Report

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
Advocate ,
Dec 14, 2021 Dec 14, 2021

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

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
Engaged ,
Dec 21, 2021 Dec 21, 2021

Copy link to clipboard

Copied

I have a few ways to do this, but at this time maybe not as automated as you would like. I have an idea for a new script that does rename/relink from a CSV spreadsheet of "old name" and "new name" columns, but it's still on the drawing board. Anyone interested in such a thing, chime in. It's what users ask for that rises to the top of the to-do list.

 

For now, have a look at these scripts and see if either is any help:

https://www.marspremedia.com/software/indesign/links-rename-selected

https://www.marspremedia.com/software/indesign/links-grep-rename

 

William Campbell

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Dec 21, 2021 Dec 21, 2021

Copy link to clipboard

Copied

That would be very useful for renaming styles in multiple documents. 

 

There is something similar for Adobe FrameMaker by Silicon Prairie Software (actually, a series of plugins). It creates a document with a table with all styles or all used styles; you then fill in the new names in the table. 

David Creamer
Adobe Certified Instructor, Adobe Certified Professional, and Adobe Certified Expert

Likes

Translate

Translate

Report

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
Engaged ,
Dec 21, 2021 Dec 21, 2021

Copy link to clipboard

Copied

LATEST

Interesting. If I understand correctly, such a script is not difficult. Is the goal to simply rename the existing styles, nothing more? If style name equals "this," change its name to "that"? A list of "this" and "that" being rows of CSV.

 

William Campbell

Likes

Translate

Translate

Report

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