Change name after changing creation date

Is there a way to set a trigger for running a smart rule after the created date has been manually changed in DT?

I want to rename the file based on the created date and change the name after the the created date has been changed.

There’s no such trigger yet. One workaround might be to use a scheduled smart rule but this would require that the documents which need to be renamed are marked in some way.

In my mind, creation date is like a birthday. That does not change either. You could instead use a custom metadata field or one of the other date properties. Though I doubt that triggers exist for those, either.

1 Like

@chrillek I wanted to use the creation date as the invoice date. If I create a custom metadata date, how would you change the filename after changing this date? Apply a rule manually on the document after changing the date?

The following refers to my experience in Germany – everything might be different in your place.

Every invoice has to contain the invoice date as text (at least in the EU) for VAT purposes anyway. So I don’t see the point of copying it to the creation date.

What you intend to do (using some date in the record itself to create a new name) has been discussed very often here. You might want to search for “rename date” or something like that. I also proposed a script that can be used in a smart rule (search for “replace hazel maybe”). But that would be useful only if you received similar documents regularly and also want to sort them into different databases/groups.

1 Like

@chrillek Thanks.

So I don’t see the point of copying it to the creation date.

I want to mimic a feature of the Receipts App. This App scans the PDF for Dates and automatically set the document date. It uses some kind of ML and can be trained:

Sometimes this does not work, so I want to have in DT the possibility to change the document date manually (maybe by using a custom meta data date).

I also proposed a script that can be used in a smart rule (search for “replace hazel maybe”).

Thank you. I will have a look at it.

And what happens when you store that document in DT, e.g. what does its document date tell you?

Aside: instead of trying to emulate another application’s behaviour, it might be beneficial to check out what DT can already do. Finding dates in PDF files being one thing.

1 Like

I like setting the creation date to the document date, too - it makes it easy to sort in date order when in DTTG (and I generally don’t need to know when the file was created on my computer).

What about using a script to prompt for the date you are manually setting which then re-names the file?

I cobbled one together to set custom meta data (document description, author/ from, recipient, brief description and date) which then renames the file with the date in the file name.

This is exactly what I’m working on. Do you mind sharing your script?

Yes - of course. I’m away from my Mac but will post it when back. :slightly_smiling_face:

1 Like

Hi @Lynx

I tweaked what I had to take out the custom metadata (which I’m guessing you don’t need).

Will something like this do the job? It works ok at my end.

tell application id "DNtp" -- the following code block operates within DEVONthink and uses the DT AppleScript dictionary
		set theRecords to the selected records
		if theRecords is {} then error "Please select some records."
		repeat with thisRecord in theRecords
			set currentName to name without extension of thisRecord
			set theCreationDate to creation date of thisRecord
			display dialog "Enter date of document in DDMMYYYY format for " & currentName & ". Creation date is currently " & theCreationDate default answer "" buttons {"Cancel", "OK"} default button 2
			set theDate to the text returned of the result
			set theYear to (characters -4 thru -1 in theDate) as string
			set theMonth to (characters -6 thru -5 in theDate) as string
			set theDay to (characters -8 thru -7 in theDate) as string
				set year of theCreationDate to theYear as integer
				set month of theCreationDate to theMonth as integer
				set day of theCreationDate to theDay as integer
				set hours of theCreationDate to 0
				set minutes of theCreationDate to 0
				set seconds of theCreationDate to 0
				set creation date of thisRecord to theCreationDate
			end try
			set the name of thisRecord to currentName & " " & theDay & "." & theMonth & "." & theYear
		end repeat
	on error error_message number error_number
		if the error_number is not -128 then
			display dialog error_message buttons {"OK"} default button 1
		end if
	end try
end tell

I solved it manually
Right button on the file
-Get info
Enter the date you want
You show the column in the metadata and you have the files sorted as you want.

Only sort of on-topic, but actually I do the same thing - on scanning, I change the created date to the date the document rather than the digital record was created. That makes more sense to me, and allows me to sort the records by the document date (= created date).

I agree with that sentiment - which is actually why I want the digital created date to reflect the date the paper document was produced (no, what I actually want is for the document never to exist on paper, to be sent to my digitally the day it is produced and to automatically drop from my mail app to DT, where it would ideally be dealt with fully automatically; you know, salary statements automatically filed to income, invoices automatically filed to trash, that sort of thing…)

1 Like

Though I see your point, I never use the creation date for anything. The document date (or whatever we want to call it – invoice date etc.) is part of the record’s name in my case.

1 Like

To me that is perfectly reasonable, possibly even the better logic. It is, however, aesthetically less pleasing and therefore quite unacceptable :smiley:

(Actually, I’m not sure it’s the better logic… I’ve just tried something and found that when looking for something based on its name, I’ll often change the sort order from created to name, something which I couldn’t do if the name and date were one. As is so often the case: DT caters to a wide range of ppl and their needs - its flexibility is amazing,)