The code below seems to work on the files you posted. I'm using CC2018 on High Sierra.
I think the usage of parent and child is really confusing so I changed the dialogs a bit. The script now asks you to choose the placed file first, followed by the folder containing ID files to search through.
You might have to watchout for folders with too many files, you could run into memory issues.
(*
Rob Day 2015-2018
Opens all of the ID files in a chosen folder and checks for the parent of specified placed child file.
If the link name is not found document is closed
*)
global mylinkname
tell application "Finder"
set the cFile to (choose file with prompt "Choose a Placed File to Search for.")
set mylinkname to name of cFile
set the dfolder to (choose folder with prompt "Choose a Folder containing InDesign Files to Search.")
set flist to (every file of entire contents of folder dfolder) as alias list
my checkLinks(flist)
tell application "Adobe InDesign CC 2018"
activate
end tell
end tell
-------------------------------Functions----------------------------------
on checkLinks(flist)
tell application "Finder"
repeat with f in flist
--check for InDesign fiiles
if creator type of file f is "InDn" then
tell application "Adobe InDesign CC 2018"
--activate
set user interaction level of script preferences to never interact
try
open f
tell active document
--use the links file path rather than the name
set llist to file path of every link
set nlist to my getNames(llist)
if mylinkname is not in nlist then
close
end if
end tell
end try
set user interaction level of script preferences to interact with all
end tell
end if
end repeat
end tell
end checkLinks
--gets the last item of the file path (the file name)
on getNames(theList)
set nlist to {}
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
repeat with x in theList
set n to every text item of x
copy last item of n to end of nlist
end repeat
return nlist
end getNames