Set name to first three lines of document?

Anybody can help me with a script that would set the name of a text/rich text document to the first three lines (that would be about 400 characters) of the document?
Thank you very much! Louise … :arrow_right::smiley: :smiley: :smiley:

That code should work (but DT automatically removes the feeds as names with multiples lines are not supported):

tell application "DEVONthink Pro"
	set theSel to the selection
	repeat with theRecord in theSel
		set theText to plain text of theRecord
		if theText is not missing value and theText is not "" then
			set theLines to paragraphs 1 thru 3 of theText
			set the name of theRecord to (theLines as string)
	end repeat
end tell

Christian, thank you very much for this quick reply :smiley:
I changed

set theLines to paragraphs 1 thru 3 of theText


set theLines to characters 1 thru 400 of theText

so i also get expressive names when the first paragraphs dont contain much text.

P.S. I already praised DEVONthink and their developers for their helpfulness towards customers in some Mac Forums :wink: