Fill the clipboard with text and file (at the same time)

Hi,

I would like to be able to put into the clipboard some text and a picture (or any other kind of file).
Like you would get if you:

  • open a new textedit document
  • add some text
  • drag and drop an image in your document
  • select all
  • cut it

I don’t want to use TextEdit, just produce the same result. I would like to get this to work with any kind of file (picture, text file, archive, …).

So far, I have this, but I’m stuck.


set teststring to "abc"

tell application "Finder"
	set selectionList to {} & selection as list
	set testfile to first item of selectionList
end tell

set testcontainer to teststring & testfile

set the clipboard to testcontainer

This script set the clipboard to the string “abcSystem:private:tmp:Archive.zip”
I would like to have in the clipboard the string “abc” and the actual file.

Thank you for your help.

Sounds like you’re trying to build an rtfd document in the clipboard. Isn’t going to happen – although you can copy the content of an rtfd and paste it back to a new one, the clipboard doesn’t understand concatination (adding parts).

Perhaps if you tell us what you want to accomplish we can suggest ways of getting there.

My final goal is to be able to build a droplet, which, when receiving files, would copy them to the clipboard accompagned by some text.
Example:
If I drop an archive nammed try.zip on it, it would set the clipboard to:
File “try.zip”, size 1MB
and the actual file.

I would then be able to paste the clipboard value to a Mail.app message.
Note: I don’t want to build the message using Mail.app dictionary, as I might already be writing this message (and have set subject, body content, sig…) and didn’t find a way to interact using applescript with a message not created through applescript.

Thanks.