Script for moving an item to target group by name?

Is there a script that allows me to move an item to a target location?

In reviewing a folder (group) I would like to quickly move obsolete items to an “archived” folder.

I have found this from @BLUEFROG

move theRecord to the current group

But how would I specify the target group by name? (Haven’t done AppleScritping in a while :slight_smile:

You could use create location, see AppleScript: A brief description of “create location” and a handler.

A smart rule and its File action might also be an option:

1 Like

Thanks for the tips.

I have found a very old post by @cgrunenberg here

Modified it slightly and came up with this:

tell application id "DNtp"
	try
		set theDatabase to current database
		set theRecords to (selected records)
		set theGroup to create location "/z PROJECTS DONE"
		-- set theGroup to parent named "z PROJECTS DONE" of theDatabase
		repeat with theRecord in theRecords
			move record theRecord to theGroup
			display notification "Moved <" & name of theRecord & "> to 'z PROJECTS DONE'" with title "Moved group to DONE"
		end repeat
	end try
end tell