Often I find myself at the command line wanting to copy files to the clipboard, so that I can paste them as attachments in Mail. If I have an image file, image1.png
, I can accomplish this with
osascript -e 'tell app "Finder" to set the clipboard to ( POSIX file "image1.png" )'
If I execute the above command and then open a new message in Mail and press command V, the image file is pasted as an attachment. Note that pbcopy
is apparently not a solution here, because this would copy the contents of the file and result in junk when pasted with command V.
My question is how can I do the same thing with multiple files? Suppose I want to paste both image1.png
and image2.png
. This is trivial from Finder (select them both, command C, then switch to Mail and command V; voila, both files show up as attachments)… but how can I do this from the command line?
make new attachment with properties {file name:this_file} at after last paragraph
, using a repeat loop overargv
. I'm wondering if the answer to the original question, however, is indeed simply "you can't do this with Applescript". – JCOidl Oct 6 '12 at 20:00