0

I would like to be able to add items to a list in Reminders in a specific order, using AppleScript.

Using the following script, however, adds the items in a different order each time I run it:

set my_reminders to {"item4", "item3", "item2", "item1", "item"}
tell application "Reminders"
    tell list "Reminders"
        repeat with the_name in my_reminders
            set this_reminder to make new reminder with properties {name:the_name as string}
        end repeat
    end tell
end tell
bmorgan
  • 525
  • 5
  • 8

1 Answers1

1

It seems that adding a short delay after the reminder creation solves the problem:

set my_reminders to {"item4", "item", "item2", "item1", "item3"}
tell application "Reminders"
    tell list "Reminders"
        repeat with the_name in my_reminders
            set this_reminder to make new reminder with properties {name:the_name as string}
            delay 1
        end repeat
    end tell
end tell
Michele Percich
  • 1,872
  • 2
  • 14
  • 20
  • This works, but I would describe it as a workaround, rather than solving the problem, as it makes the script very slow for a large number of items. I'll go with this method for the moment, but hopefully there is a more elegant solution. – bmorgan Nov 13 '12 at 17:41
  • To shorten the time problem because of the delay, you can probably shorten the 1 second down to .5 or even less. Just keep using smaller time lengths until the script stops working to find the lowest number you can use. – regulus6633 Nov 13 '12 at 23:45