Combining TextEdit files containing hyperlink

Hi all!!!
I have been silent for some time, but still developing scripts …

I have a question:
I need very often to combine TextEdit files containing only 1 line of text each, but the text contains embedded hyperlink.
I basically need to open access to the file#1, copy all content and past it at the end of file#2 on a new line.
When I do this, I completely alter the hidden hypertext.

The files are generated using a subroutine kindly provided by Shane:

set styledText to ParsingNameAndURL(theList1)
-- first turn attributed string into RTF data
set theData to styledText's RTFFromRange:{0, styledText's |length|()} documentAttributes:{DocumentType:current application's NSRTFTextDocumentType}
-- write the data to the file
theData's writeToFile:posixPath atomically:true

Any suggestion?
Thanks a lot.

L.

This will get the contents of two files and write then to a third. You should be able to adjust it to your needs.

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit" -- needed for RTF

set posixPath1 to POSIX path of (choose file with prompt "Choose an RTF file" of type {"rtf"})
set posixPath2 to POSIX path of (choose file with prompt "Choose another RTF file" of type {"rtf"})
set destPath to POSIX path of (choose file name default name "Output.rtf")
-- read file as RTF data
set theData to current application's NSData's dataWithContentsOfFile:posixPath1
-- create attributed string from the data
set {theStyledString, docAttributes} to current application's NSAttributedString's alloc()'s initWithRTF:theData documentAttributes:(reference)
if theStyledString is missing value then error "Could not read RTF file"
-- make copy you can modify
set theStyledString to theStyledString's mutableCopy()
--- read second file as RTF data
set theData to current application's NSData's dataWithContentsOfFile:posixPath2
-- create attributed string from the data
set {theStyledString2, docAttributes} to current application's NSAttributedString's alloc()'s initWithRTF:theData documentAttributes:(reference)
if theStyledString2 is missing value then error "Could not read RTF file"
-- make attributed linefeed
set styledLF to current application's NSAttributedString's alloc()'s initWithString:linefeed
-- append to make single attributed string
theStyledString's appendAttributedString:styledLF
theStyledString's appendAttributedString:theStyledString2
--   turn attributed string into RTF data
set theData to theStyledString's RTFFromRange:{0, theStyledString's |length|()} documentAttributes:docAttributes
-- write the data to the file
theData's writeToFile:destPath atomically:true

Although I dont know AppleScriptObjC, I can appreciate the logic of your script.
Thanks a lot !!!

It is still a bit puzzling that something like this which is very intuitive to do manually (with keyboard and/or mouse clicks) and it can be easily done using UI scripting, yet it is impossible to do it with AS or it becomes complicated at the time of using ObjC …