Skip to main content
Participant
December 14, 2021
Question

Renaming links for already-placed image files

  • December 14, 2021
  • 3 replies
  • 3144 views

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. 

This topic has been closed for replies.

3 replies

willcampbell7
Legend
December 21, 2021

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
Dave Creamer of IDEAS
Community Expert
Community Expert
December 21, 2021

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: Community Expert (ACI and ACE 1995-2023)
willcampbell7
Legend
December 21, 2021

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
m1b
Community Expert
Community Expert
December 14, 2021

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");
m1b
Community Expert
Community Expert
December 15, 2021

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".