I don’t seem to be able to test if a record is a plain text file. With “theRecord” set to the record of a plain text file, the following evaluates to false …
tell application "DEVONthink Pro"
type of theRecord = txt
end tell
According to the documentation, the name of the type is “txt”. When I evaluate the following in the AppleScript Editor …
tell application "DEVONthink Pro"
type of theRecord
end tell
… I get “text” in a purple font. But evaluating …
tell application "DEVONthink Pro"
type of theRecord = text
end tell
tell application id "com.devon-technologies.thinkpro"
try
set this_item to the selection
if type of this_item is txt then
-- do something important
else
-- do something less important
end if
end try
end tell
I had to make some modifications to get the script to run. Here is the script I used.
tell application id "com.devon-technologies.thinkpro2"
try
set this_item to the selection
if type of item 1 of this_item is txt then
display alert "yes"
else
display alert "no"
end if
on error msg number num
display alert msg
end try
end tell
I get an alert saying “no” when I run it with a single plain text file selected in DT.
tell application id "com.devon-technologies.thinkpro2"
try
set theDatabase to current database
set these_items to the selection
repeat with this_item in these_items
set myType to (type of this_item as string)
if kind of this_item is "Text" then
display alert "yes, Type: " & myType
else
display alert "no, Type: " & myType
end if
end repeat
end try
end tell