Things 3 - AppleScript - move to do's

Hi,

I'm trying to get some automation into Things 3.

I want to get to-do's moved around between areas and lists and have been trying with applescript, but so far without luck.

For example: I'm using the time sector system, so when I drag a todo from Today to Next Week area, I want it to automatically be set to 'Anytime' (so moved to the 'Anytime' list) so it's removed from my daily list.

Also, I have some repeating items. Once they appear in my Today list, I want them to move away from the 'admin-repeated' area and into the 'admin' area.

What I've tried so far is this:

tell application "Things3"
   
   set theTodos to to dos of list "Today"
   
   repeat with aTodo in theTodos
      
      if area is "TestArea" then
         move to list "Anytime"
      end if

   end repeat
   
end tell

Not a Things user -- but you don't need to set theToDos then iterate through that, you can do it directly from the list. And in your loop you have to tell AS what object to test and move. Try:

tell application "Things3"
    repeat with aToDo in to dos of list "Today"
        if area of aToDo is "TestArea" then
            move aToDo to list "Anytime"
        end if
    end repeat
end tell

Thanks for your input, Nige. Unfortunately this didn't solve it. I don't get any error message, but nothing happens.
I'm new to AppleScript, so I'm probably missing something rather basic, but I tried to look here for a solution Using AppleScript - Things Support without luck.

Start here, which is where I grabbed bits of the code above.

But you'll probably find you're approaching things are "upside down" -- object-based systems often work opposite to how we think of them and I'm guessing that while a to do is in an area it doesn't have an area property you can query. Instead, you ask the area about the to dos it contains.

This code snippet from the above link appears to back that up:

tell application "Things3"
    repeat with ccToDo in to dos of area "Cultured Code"
        --- do something with each to do using ccToDo variable
    end repeat
end tell

So the question will be do you need to filter on both the "Today" list and the "TestArea" area, or is area alone enough? If it is then:

tell application "Things3"
    repeat with aToDo in to dos of area "TestArea"
        move aToDo to list "Anytime"
    end repeat
end tell

Yes, the thing is I need to filter by both. The items affected should be in both the correct Area and the correct List. I could theoretically start from the Area and filter based on List, but I don't get that to work either.

So you need to find out the available properties of the to do object. What do you get if you run the following?

tell application "Things3"
    repeat with aToDo in to dos of area "TestArea"
        return properties of aToDo
    end repeat
end tell

There's probably a way to filter by both, but Plan B would be to

  1. Make a list a of to dos in the "Today" list
  2. Make a list b of to dos in the "TestArea" area
  3. For each item in list a
    a. If it is also in list b, move it to the "Anytime" list

I made two test to-do's to try it out and get this result:

status:open, tag names:Finances, cancellation date:missing value, due date:missing value, class:selected to do, modification date:date fredag den 25. november 2022 kl. 23.02.51, contact:missing value, project:missing value, area:area id TxMxbMWf9dGDSB8gFjr7AE, notes:, activation date:missing value, id:3zMYJH7uAVvJMnR9wYFUkv, completion date:missing value, name:todo1-anytime, creation date:date fredag den 25. november 2022 kl. 23.01.42

Could you specify how the Plan B scripting would look?

That looks promising. Even better, I remembered this morning that my ex boss played with Things3 for a while and, sure enough, it's still around. So:

tell application "Things3"
	set areaID to id of item 1 of (get every area whose name is "TestArea")

	set theList to every to do of list "Today"
	repeat with aToDo in theList
		if area of aToDo is area id areaID then
			move aToDo to list "Anytime"
		end if
	end repeat
end tell

It reads pretty straightforward, but ask if you've questions.

Wow! Thanks a lot, that made the trick!! :smiley: