How to fix this script?

with some help from the great people here I received this script to solve this problem

I collect my student messages from Safari. I paste them in TextEdit. The structure of the resulting RTF file is always the same as it contains 2 Hyperlinks and a date in plain text.

This is the script

set filePath to (path to desktop folder as text) & "linkTest.rtf"

set startDelimiter to "{HYPERLINK \""
set endDelimiter to "\"}}"
set hyperlinks to {}

set rtfText to read file filePath
set text item delimiters to startDelimiter
set theItems to text items of rtfText
if (count of theItems) is greater than 1 then
	set text item delimiters to endDelimiter
	repeat with i from 2 to count of theItems
		set a to text items of (item i of theItems)
		set end of hyperlinks to item 1 of a
	end repeat
end if
set text item delimiters to ""
set adjustedText to theItems as text
return hyperlinks
writeTo(adjustedText, filePath, false, string)
(*==================== SUBROUTINES ===================*)
on writeTo(this_data, target_file, append_data, mode) -- append_data is true or false, mode is string etc. (no quotes around either)
		set target_file to target_file as Unicode text
		if target_file does not contain ":" then set target_file to POSIX file target_file as Unicode text
		set the open_target_file to open for access file target_file with write permission
		if append_data is false then set eof of the open_target_file to 0
		write this_data to the open_target_file starting at eof as mode
		close access the open_target_file
		return true
	on error
			close access file open_target_file
		end try
		return false
	end try
end writeTo

however the script requires for me to always copy the file to the desktop and chage the name to “linkTest.rtf”

which is not a big deal,

the problem are:

the script doesn’t return the date of the message which is in plain text in the file
I get the parsed hyperlinks in the result window of Applescript

there must be some changes to the script so I can choose the file to process with his own name
select a name for the processed file
keep the date information.

As an example I add one records as they appear after manually parsing the link in TextEdit:

The subject:
RE: Good day
[hyperlink for:]

Student Name
[hyperlink for:]


(plain text)

then after a series of carriage returns another similar sequence with 2 hyperlinks and the date in plain text

How can I fix all this?

Kind reagards to all -----

Dan wan