Imported from the Apple Support Forums via the Wayback Machine 🔗
I've created a TextEdit.rtf document with some text, then dragged a picture file into it, which adds the picture. When saved, this becomes an .rtfd "file" (understandable). Two ways I've been able to access the contents of this "file" are using "ls" in Terminal or using "Show Package Contents." In the end, I'm not quite certain whether to regard the .rtfd "file" as a folder or as a package.
In any event, the .rtfd "file" can be opened and edited manually (changing the text or the picture or both) and then saved. My question is: how can such editing be done with AS?
The package contents shows the text as the file "TXT.rtf" (reasonable). so using the path to TXT.rtf I tried overwriting TXT.rtf using Terminal (or do shell script). Something obviously happens, but what I wind up with is a TXT.rtf file that can't be opened. (If I try to add text to TXT.rtf, nothing happens.)
Imported from the Apple Support Forums via the Wayback Machine 🔗
I have learned this:
If I create a new .rtf file containing the new text I want, I can use "mv" in Terminal (or do shell script) to replace the TXT.rtf file -- BUT, in the process, the picture file in the .rtfd file disappears. Progress? Maybe, but I'm not sure.
0
osimp·
Imported from the Apple Support Forums via the Wayback Machine 🔗
And this:
Using the "mv" approach, I can successfully replace the picture file with another -- without disturbing the text.
But my greater interest is in replacing the text (i.e., the TXT.rtf file) with a new one, which I can do but not without the picture file disappearing. I guess I need to better understand packages.
0
pidge1·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Hi
I had a similar problem, i used something similar to this to put the image file back in:
tell application "TextEdit" to tell document 1 to make new attachment with properties {file name:choose file}