-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRelinkBookDocuments.jsx
52 lines (40 loc) · 1.39 KB
/
RelinkBookDocuments.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Author: Raphael Matto
// Date: Dec 15, 2023
// This script updates paths for moved InDesign Documents in an InDesign Book.
// Tested on MacOs, might work on Windows.
main();
function main() {
// If there are no Books open, app.activeBook fails.
try {
var book = app.activeBook;
} catch(e) {
alert(e);
exit();
}
alert("In the next dialog, select the folder where you've moved the Book's Document files to.")
var newRoot = Folder.selectDialog("New Documents folder");
if (!newRoot) {
alert("No folder selected, exiting ...");
exit();
}
var confirmed = confirm(
"This script will replace all missing Document paths with Document paths that exist at " +
newRoot + " for the Book " + book.name + "." + " Do you want to continue?", true, "Please confirm");
if (!confirmed) {
exit();
}
var count = 0;
for (var i = 0; i < book.bookContents.length; i++) {
var doc = book.bookContents[i];
if (!new File(doc.fullName).exists) {
newPath = new File(newRoot.fsName + "/" + doc.name);
if (newPath.exists) {
doc.replace(newPath);
count++;
} else {
alert(newPath + " does not exist, skipping ...")
}
}
}
alert("Paths updated for " + count + " Documents in " + book.name + ".")
}