Hi Skip,
I’m using an older version of TextEdit, but it may be the same on your version. The open command from the dictionary:
open: Open an object.
open a list of alias – list of objects
It needs a list! If you tell TextEdit to open with a reference to a list item, then it errors. What I did is send it exactly what it wants which is a list of alias references.
Before you create a droplet it’s a good idea to make the script work first in the Script Editor or whatever. What I do is either use the Finder’s selection or put some files in a folder and get every item as alias list. Here’s an example before making it a droplet:
set f to choose folder
tell application "Finder"
set some_items to every file of f as alias list
end tell
tell application "TextEdit"
launch
activate
end tell
repeat with this_item in some_items
tell application "TextEdit"
open (this_item as list)
set t to text of front document
close front document
set d to (make new document at front)
set text of d to t
end tell
end repeat
Here the repeat variable this_item is a reference to a list item. Another way to do this is to get the contents of the reference to the list item. For example:
set f to choose folder
tell application "Finder"
set some_items to every file of f as alias list
end tell
tell application "TextEdit"
launch
activate
end tell
repeat with this_item in some_items
set c to contents of this_item
tell application "TextEdit"
open c
set t to text of front document
close front document
set d to (make new document at front)
set text of d to t
end tell
end repeat
What this does is get the value of the list item which is an alias reference. Here TextEdit allows a non-list of alias, because it is an actual alias reference which is the value of the list item.
Now that we got it working in the Script Editor, you can change it to a droplet.
on open some_items
tell application "TextEdit"
launch
activate
end tell
repeat with this_item in some_items
tell application "TextEdit"
open {this_item}
set t to text of front document
close front document
set d to (make new document at front)
set text of d to t
end tell
end repeat
end open
Note that getting the text of an rtf document in TextEdit, returns text. If you have your TextEdit preferences set to plain text, then this is one way to convert rtf to plain text.
I think this is how it goes for the most part.
gl,