Признаюсь, мне не совсем понятно, что такое «вложение» в языке TextEdit или для чего оно может быть использовано, но если вам нужен только один файл со всеми этими вложениями, этодостаточно просто:
tell application "Finder"
set thisFolder to choose folder with prompt "Please select the folder you wish to process." without invisibles
set theFileName to name of thisFolder
set theseFiles to files of thisFolder as alias list
end tell
tell application "TextEdit"
activate
set thisDoc to make new document
set pathtofile to ((thisFolder as string) & theFileName & ".rtfd") as Unicode text
tell thisDoc
repeat with thisFile in theseFiles
make new attachment with properties {file name:thisFile}
end repeat
save in file pathtofile
end tell
close front document saving no
end tell
РЕДАКТИРОВАТЬ
В комментариях приведена версия, которая применяет эту процедуру к подпапкам.Я немного очистил код (мне нравится использовать системные события лучше, чем Finder), но это тот же процесс.
set thisFolder to choose folder with prompt "Please select the folder you wish to process." without invisibles
tell application "System Events"
set subFolders to folders of thisFolder
repeat with aFolder in subFolders
set folderName to name of aFolder
set filePath to (POSIX path of thisFolder) & "/" & folderName & ".rtfd"
set fileList to (POSIX path of every file of aFolder whose visible is true)
tell application "TextEdit"
activate
set thisDoc to make new document
tell thisDoc
repeat with aFile in fileList
make new attachment with properties {file name:(POSIX file aFile) as alias}
end repeat
save in POSIX file filePath
end tell
close front document saving no
end tell
end repeat
end tell
return