Clash of type2 enumeration of "text" and "smart group" in AppleScript

It seems that the type2 enumeration of “txt” or “text” and “smart group” cannot be compiled due to the clash of those enumerations with other additions.

I try using the solution suggested by @Korm in this post by using both “text” and “txt” with no success.

I wonder if someone can advise on this matter? One alternative is to use kind instead of type but the script will become localized language-dependent?

Thank you

-- "txt" seems to be recognised as enumeration after compilation but the results are incorrect.
if each's type is in {text, txt, rtfd, rtf, markdown} then set end of l to each's item 1

Thank you!

(1) It is strange that if I use set b to type of a -- a is a plain text file, I get “text” as the return value.

(2) I did check the dictionary and under type2 “txt” is listed. I did use “txt” initially. However, the script only filter out rtf,rtfd, and markdown files but not for type==txt.

(3) Same issue for type==smart group

This is what I initially used:

if each's type is in {txt, rtfd, rtf, markdown} then set end of l to each's item 1

It could merely be a small error in the dictionary (which is manually generated). @cgrunenberg would have to respond to this.

Thanks again!

You’re welcome :slight_smile:

It’s a known ambiguity of the script suite dating back to DEVONthink Pro 1.0 which wasn’t fixed to ensure that existing scripts, both compiled and uncompiled ones, are still compatible.

But there’s a simple workaround:

tell application id "DNtp"
	repeat with theRecord in (selection as list)
		set theType to ((type of theRecord) as string)
		if theType is "text" then
			display dialog "Text"
		else if theType is "smart group" then
			display dialog "Smart Group"
		end if
	end repeat
end tell

Contrary to the kind this does not depend on the language/localization/version.

Got it. Thank you very much!

As a follow to the post#1, this will do the job.

if (each's type as string) is in {"text", "rtfd", "rtf", "markdown"} then set end of l to each's item 1