myUpdateLinksAfterMoving.jsx an InDesign document
© 2022 Gerald Hemetsberger
Here's another script on on how to get around the fact
that InDesign only works with absolute path links and not with relative references.
However, it is limited to relative links that are only below but not above the active directory.
(Continued from
https://www.hilfdirselbst.ch/...rum.cgi?post=574960)
This script is intended to update the links in an active InDesign file
when you have moved with the document to a new file location.
To do this, you only need to call the script without making any further entries in an initial dialog.
Instead, the directory name of the active InDesign document is used for some logic
to make changes to the links as "root" which is more convenient and less prone to errors than manual inputs.
Of course, the script offers the possibility to be aborted again before any actions are triggered.
We assume that all necessary linked files (assets) are part of an existing subdirectory structure
that is direct part of the folder of the active InDesign document (no referencing above).
We also assume that together with this document, the whole asset structure was copied to the new location.
On the other hand, links remain unaffected by this script
that do not point into this subdirectory structure (otherwise referencing above would be needed) or
the file is missing at the new location.
The paths of linked files are updated if they contain the name of the active folder.
The absolute path part is exchanged for the current one while the relative path parts
will be preserved as subject of the new subdirectory structure.
If the name of the active directory exists multiple times in a link, the instance lowest in the directory structure
is used while the other instances are exchanged as part of the absolute path.
Caution: The procedure will not work correctly if linked files have names that include the active folder name.
If necessary, the script will show two dialogs at the end:
1.) The list of files that are missing in the new location.
Two paths are given for a file if the file was nevertheless found at an old location
as these files are hard to uncover in InDesign's link panel.
2.) List of all files that are outside the relative path description.
(as relative linking does only refer here to folders that are inside the active directory)
Examples
------------
Assume the active document to be in a new location on drive B: which is folder "Production":
B:\Editorial\Handouts\Production\InDesign.indd
Link 1 before:
C:\Users\Default\Documents\Production-Structure\Production\picture1.psd
Link 1 after:
B:\Editorial\Handouts\Production\picture1.psd
Link 2 before:
F:\Production\Photoshop\picture2.psd
Link 2 after:
B:\Editorial\Handouts\Production\Photoshop\picture2.psd
Link 3 before:
G:\myDocuments\picture3.psd
Link 3 after:
G:\myDocuments\picture3.psd (unchanged as there is no "Production" folder)
Now start with initial checks:
Make sure that the active document is really stored under a name in a folder.
Put the name of the file, its active folder, and its absolute path in variables.