Intelligent Rules with YY instead of YYYY when renaming


I have been trying to change the name of a file with automatic rules and want to add the date. However I do not wish to add YYYY but YY, so I want to write 210321 instead of 20210321. Can anyone help me here? Thank you very much!

All the best


File renaming has been discussed many times in the Automation forums.

Where are you getting the date - today’s date, the creation date, …?

I looked but couldn‘t find any way to change YYYY to YY with operators.
I am using the document date which I first let DEVONthink extract and in case it is necessary I correct it (several automation steps)

I still don’t actually know what you’re doing - but assuming you have got a created/modified/document date then a smart rule can add that date in short form (that is DD.MM.YY) to the name using a placeholder.

Placeholders are accessed from the context menu of the change name field.

If that is not what you are looking for, could you please explain in rather more detail what it is you are doing and how you are getting there (i.e. screen shots of rules, scripts etc.) - that would make helping you easier :slight_smile:

Hello Blanc,

thanks for getting back to me. I did find the smart rules and in that way I did enter the year (in yyyy, 2021), the month (in mm, 03) and the day (in dd, 22). There is an option to enter the document date in yyyy-mm-dd (2021-03-22). However, my inner monk wants to have yymmdd (210322) in the file names.

Screenshot (sorry, only in German)

Well, I guess I have to tame my inner monk. Thanks for the support anyway! :slight_smile:

Nooooo, really, there is an option there for DDMMYY, really :slight_smile: it’s the one I posted above. I don’t know what the German equivalent is @MichaelHD, @SteffisCloud weiß das einer von euch?)

Yes, I did see DDMMYY - but I am looking for YYMMDD. :wink:

You can use an Execute Script action in a smart rule to modify the date order, if this is something you’d need done regularly…

on performSmartRule(theFiles)
	tell application id "DNtp"
		repeat with thisFile in theFiles
			set docDate to (document date of thisFile)
			set theYear to my zeropad((characters -2 thru -1 of (year of docDate as string) as string) as integer)
			set theMonth to my zeropad(month of docDate as integer)
			set theDay to my zeropad(day of docDate)
		end repeat
		set name of thisFile to (theYear & theMonth & theDay & "_" as string) & (name of thisFile)
	end tell
end performSmartRule

on zeropad(num)
	if num < 10 then
		set num to "0" & num
	end if
	return num
end zeropad

Thanks, I was just going to say that :stuck_out_tongue_winking_eye:

You could try sitting at your desk on your head?

(Sorry, I obviously didn’t look at your post properly, pls excuse)

PS That confused me :wink:

All is good! Thanks for replying so fast!

Yep, probably not the best idea for a date example. :slight_smile:

Thanks! I will try this.

No problem.

One more question: I just noticed that the placeholder uses the document date which is not always the correct vlaue. I have set a date as custom value which I use to have the correct date. It’s just called “Datum” (German for date) and formatted as date. I wonder: Could you modify your script above so that I can use this custom date value?

CleanShot 2021-03-22 at 22.51.48@2x

Or is it possible to change document date somehow? I can’t find that option anywhere.

Thank you! :slight_smile:

If you want to use a specific convention in that custom metadata field, you can use a Single-Line Text data type.

Thanks, I thought about this as well. I‘m not sure if using a meta data text field is the best idea:

I use the date for sorting and plan to use it in other scripts. Would a custom meta field text allow this? Sorting would probably work, but using the date in other Skripts? In addition I use intelligent rules to set the date based on document date - in about 70% to 80% of cases the document date is correct.

Furthermore I already have a ton of documents dated with this logic so I would have to change all of the existing ones.

Easiest would probably be if I could change the document date - if this is possible.

A text field would still be sortable based on its format, e.g., 2021-03-22.

You can change the document date via smart rules but it’s not going to show in the item list or Info inspector in a format of your choosing.

Thanks. I start feeling guilty, but I have to ask: How can I change the document date? I can see creation and modification date but not document date. I might have to calm my inner monk, but I believe I can live with yyyy-mm-dd which is possible to use. THANKS a lot! :slight_smile:

The document date is a property filled by DT automatically based on the first date extracted from the text of a document. So whilst you can’t (to the best of my knowledge; this property is marked “read only” in the script dictionary) change the document date, you don’t actually have to use that date to change the name of your file. You could just as easily use the creation date, which you can change.

I set the creation date of all my files to the actual document date (using a simple rule to equate the creation date to the document date in some cases, but more complex scripts to extract the correct document date and equate the creation date to it in other cases). The addition date remains put, so I can still see when I actually added the file to DT.