Two pieces of AppleScript: one works, one fails—why?

There may be a little good news. Following a lot of cutting and pasting of results from Script Editor and checking manual search results in DT it appears as if the problem may be resolved by dispensing with the .md extension when assembling the file name in the script. If that is present (even when manually searching in DT) entries seem not to be found. Removing the extension produces promising looking results from the script (in that the script actually produces a UUID). I still need to check that the UUIDs produced are those of the actual, relevant entries.

For those who have assisted, many, many thanks. I guess the problem is that I have 18,000+ markdown files all divided into relevant years and with a generated table of contents for each year. (The latter being the reaon I need to check that the UUIDs are not being produced from the tables of contents.) That means I have an awful lot more records than those of you who have been kind enough to test.

Life has to go on…I’ll do some more testing later. In the meantime, huge apologies for the length of this thread and the work generated for all who have tried to help.

Stephen :pray: