## this is what I called _RelinkerFull.scpt tell application "Adobe InDesign 2021" tell active document set linkList to links set errInfo to "" set fixedLinks to {} set thisYear to "" repeat with currentLink in linkList if (currentLink's status) is not normal then -- Checks for broken links only set linkPath to (currentLink's file path) as string set fileName to (currentLink's name) as string set nameLength to length of fileName set basePathLength to ((length of linkPath) - nameLength) set newFolderPath to text 1 thru basePathLength of linkPath set folderName to text (basePathLength - 4) thru (basePathLength - 1) of newFolderPath set newFileName to folderName & "_" & fileName set newLinkPath to newFolderPath & newFileName try relink currentLink to newLinkPath as alias try update currentLink end try on error err try tell application "FileMaker Pro 18 Advanced" activate tell database "ScannedPhotos" set data cell "SearchName" to linkName do script "Searcher" delay 2 set newLinkPath to cell "Image Path" of current record set newFileName to cell "FileName" of current record end tell end tell set currentLink's name to newFileName relink currentLink to file newLinkPath as alias update currentLink set errInfo to (errInfo & return & currentLink's name) end try end try set end of fixedLinks to newLinkPath end if end repeat if (count errInfo) > 0 then display dialog ("Can't relink:" & errInfo) return fixedLinks end tell end tell ## This is _YearLabelAll.scpt tell application "Adobe InDesign 2021" tell active document set linkList to links repeat with currentLink in linkList set imageRef to parent of currentLink try set thisPage to parent page of imageRef set thisFrame to the parent of imageRef set theBounds to geometric bounds of thisFrame ## bounds are top, left, bottom, right set labelTop to ((item 1 of theBounds) + ((item 3 of theBounds) - (item 1 of theBounds)) / 2) - 0.25 set labelLeft to ((item 2 of theBounds) + ((item 4 of theBounds) - (item 2 of theBounds)) / 2) - 0.75 set labelBottom to labelTop + 0.5 set labelRight to labelLeft + 1.5 set currentLink to item link of imageRef set linkPath to (currentLink's file path) as string set fileName to (currentLink's name) as string set nameLength to length of fileName set basePathLength to ((length of linkPath) - nameLength) set folderName to text (basePathLength - 4) thru (basePathLength - 1) of linkPath tell thisPage set theLabel to make text frame with properties {geometric bounds:{labelTop, labelLeft, labelBottom, labelRight}, item layer:"Image Labels"} set contents of theLabel to folderName tell first text of theLabel set applied font to "Minion Pro" set point size to 48 set justification to center align set font style to "Bold" set fill color to "R=237 G=209 B=28" -- has to be defined swatch in InDesign end tell end tell on error (e) activate (display alert (e)) end try end repeat end tell end tell ## This is _YearLabelSelected.scpt set linkName to "" set folderName to "" set thisItem to 1 tell application "Adobe InDesign 2021" tell active document set selList to selection if length of selList > 0 then set itemCount to length of selList repeat until thisItem > itemCount set selItem to item thisItem of selList try if class of selItem is rectangle and (count of images of selItem) > 0 then set imageRef to image 1 of selItem else if class of selItem is image then set imageRef to selItem else error ("image not selected") end if set thisPage to parent page of imageRef set thisFrame to the parent of imageRef set theBounds to geometric bounds of thisFrame ## bounds are top, left, bottom, right set labelTop to ((item 1 of theBounds) + ((item 3 of theBounds) - (item 1 of theBounds)) / 2) - 0.25 set labelLeft to ((item 2 of theBounds) + ((item 4 of theBounds) - (item 2 of theBounds)) / 2) - 0.75 set labelBottom to labelTop + 0.5 set labelRight to labelLeft + 1.5 set currentLink to item link of imageRef set linkPath to (currentLink's file path) as string set fileName to (currentLink's name) as string set nameLength to length of fileName set basePathLength to ((length of linkPath) - nameLength) set folderName to text (basePathLength - 4) thru (basePathLength - 1) of linkPath tell thisPage set theLabel to make text frame with properties {geometric bounds:{labelTop, labelLeft, labelBottom, labelRight}, item layer:"Image Labels"} set contents of theLabel to folderName tell first text of theLabel set applied font to "Minion Pro" set point size to 48 set justification to center align set font style to "Bold" set fill color to "R=237 G=209 B=28" -- has to be defined swatch in InDesign end tell end tell on error (e) activate (display alert (e)) end try set thisItem to thisItem + 1 end repeat end if end tell end tell