Help me, please

Hello,
I want, but I can’t make a substring of text variable, for example I want from chain “filename.pdf” make string “filename”. How can I do?

I was try

tell “Finder”

set FILE_NAME to name of selection (* selection name is “WR12345.pdf” )
set SHORT_FILE_NAME to left (FILE_NAME, lenght ((FILE_NAME) -4)) (
I want substring “WR12345” *)

end tell

If You know, how do it, tell me, please

Thanks a lot, best regard

Ad@mS

(*Uses offset command from Standard Additions
will look for ".pdf" extension in filename and
return just the text before the extension. If the filename
has more than one extension, "WR12345.pdf.pdf" will still
return WR12345.
*)
tell application "Finder"
	set FILE_NAME to name of selection (* selection name is "WR12345.pdf" *)
	set extPos to (offset of ".pdf" in FILE_NAME) - 1 --get the point at which ".pdf" begins in the string
	if extPos = -1 then --then the extension wasn't found in the file name
		--do something
	else
		set SHORT_FILE_NAME to characters 1 thru extPos of FILE_NAME as string --get the characters before the extension	
	end if
end tell

Good luck!