PDA

View Full Version : Applescript to attach documents


tompos
2008-01-18, 04:06 AM
Hallo,

I am currently switching from kGTD to OmniFocus. In my earlier setup I often attached files or folder as aliases to a specific project to get an easy access to project materials or reference files. In OOP such aliasas were displayed by a nice little button with the file/folder name as button text.

I know that files can be attached to OmniFocus, too. But the name of the file or folder is omitted and only the clickable icon is visible. This may be fine, but if you have several attachments with identical icons it may get confusing.

So I tried to write a small script to include an attachment and its filename to a note. I started to tell the note of a task (I just leave out the tell... end tell statements)

make new file attachment with properties {file name:myfile, embedded:false}

as mentioned in the Forum before. This works fine and appends the attachment at the end of the note. But I don't know how to attach the file name.

set myName to (myfile as string)
insert myName at after last paragraph

does not work, the text is not included, while

set myName to (myfile as string)
insert myName at before first paragraph


works fine although the text is now far away from the attached document.
Do I need some kind of "make new paragraph..." command?

Best wishes
Tom

RobTrew
2008-01-20, 09:21 AM
Two points -

1. The fact that a line like:insert "Some Text" at after last paragraph
raises no error but has no effect does look like a bug, and might usefully be reported.

2. An alternative which does seem to work is:make new paragraph at end of paragraphs with data "Some new Text"

tompos
2008-01-20, 10:29 PM
Thanks, this solution works for me.
And as always with Applescript, the solution seems very simple (after someone shows it to you ;-) )

Best wishes
Tom