How to go through all documents in a database (to make sure none of them is only located under a tag)?

I want to make sure none of the documents in a database are only located under a tag.

pete31 pointed out a great script for this.

However this script is goes hrough the selected documents, how can I go via Applescript through all documents in the database?

I tried

set theRecords to records in current database

but this returns a weird number of documents…

A very basic but faster script could look like this:

tell application id "DNtp"
	try
		set theDatabase to current database
		set theRoot to root of theDatabase
		set theRecords to contents of theDatabase whose location begins with "/Tags/"
		repeat with thisRecord in theRecords
			replicate record thisRecord to theRoot
		end repeat
	end try
end tell

BTW:
File > Verify & Repair Database… will recognise & repair such items in the next release too.

3 Likes

Seems I used selected records for testing and didn’t think the final usage through. The simple solution to be able to select all tags is a search for tags:*

Thanks for the script.

So, to get all documents I write

set theRecords to contents of current database

Cool! I’m always learning…

And, of course, I can see your script is certainly faster, because it selects in the first place only the problematic records.

2 Likes

I’m learning even more. :grinning_face_with_smiling_eyes:

That’s what we all hope for on a daily basis. :slight_smile: