Can you please help me with these automation?

Greetings,

I’d like to have the following automations:

  1. Deleting the files trashed after, say, 30 days

  2. When I move a file from the Download folder of my Mac into DT£, then the file is deleted from the Download folder

Don’t know if there’s a script for them, I’ve searched inside DT3 and I’ve found nothing.

Or as alternative question: where can I learn about automation like these, so that I can run on my own in the future? :wink:

The first task should be possible with a smart rule.

There’s a chapter on automation in the handbook and this forum is full with posts on smart rules and scripting.

2 Likes

To remove the original file while importing use ⌘ + dragging.

1 Like

Do you know what, I’m not sure whether that is true. There is no obvious date (e.g. added or modified) which would show when the record was moved to trash. Without that automatic deletion after a period of time is not possible. The only way I could think of doing this would be to use custom metadata (one smart rule to set the custom metadata to the current date, one to delete any file whose custom date is not within the last 30 days and is different to the generic date 1.1.2001); however, I have just checked: smart rules cannot be set to act on location Trash. So we’d be back to scripting…

Move how?

1 Like

I mean…

I download a file from the Web, and the file goes to the Download folder on the Mac.
Then I move the file into DT3, but the original file is still in the original folder, so I have to delete it by hand.

Wasn’t aware of it.
It solves the second question.
Thank you!

I’ll have a look, so that I can start to learn more about automation.

Now that you mention it… right. I didn’t think of that

What database are you specifically targeting the Trash of?

Attached is a simple reminder script you can attach to the Inbox of a database. (Technically you can attach it to any item in a database, but the Inbox is ever-present so it’s an easy option to take!)

Purge Trash After N Days.scpt.zip (2.4 KB)

And the code…

property maxDate : 30

on performReminder()
	tell application id "DNtp"
		set currentDate to (current date)
		set trashedKids to (children of trash group of (current database)) -- of every database
		if trashedKids ≠ {} then
			repeat with thisKid in trashedKids
				set dateAdded to (addition date of thisKid)
				set dateDifference to (((currentDate - dateAdded) / 3600) / 24) as integer
				if dateDifference > maxDate then
					delete record thisKid
				end if
			end repeat
		end if
	end tell
end performReminder
`1``

Jim, is the addition date not the date the record was added to the database rather than the date the record was moved to the trash group of that database?

Yes

So bear with me here, doesn’t that mean that the script will delete any record which was added to the database more than 30 days ago, rather than to the trash? Sure, if the scope is limited to the Trash, then no immediate harm is done, but it still doesn’t do what the OP was asking after. Or am I missing something?

I am asleep :sleeping:
I’ll read this in a bit.

If you’re asleep, shouldn’t you be - um - asleep? :crazy_face: This forum needs a DND mode :smiley:

2 Likes