Unify Date In Names -> add day of week

I love Unify Date In Names, but I’d like to add the day of the week also. Like this: 2025-02-27 (THU). Can you help me?

I don’t know what Unify Date in Names is, but there’s a placeholder “weekday” in smart rule actions.
Alternatively, a script can set record names.

I use an Applescript to assign record names in a standard format
that includes the date (yyyy-mm-dd)
The script can easily add the weekday

@chrillek it’s one of the default smart rules:

As you note, there is a Weekday placeholder. But that uses the full name of the weekday. At little RegEx can fix that:

If you want the weekday to be uppercase, you can add this smart rule script:

on performSmartRule(theRecords)
	set AppleScript's text item delimiters to " "
	tell application id "DNtp"
		repeat with theRecord in theRecords
			set theName to text items of (name of theRecord as text)
			set theWeekday to item 2 of theName
			set changeCase to (do shell script "echo " & quoted form of theWeekday & " | tr '[:lower:]' '[:upper:]'")
			set item 2 of theName to changeCase
			set name of theRecord to (theName as string)
		end repeat
	end tell
end performSmartRule
1 Like

I see, and your solution works. However, here’s what I’d do:

  • Omit the final Scan Name and Change Name parts in your Smart Rule
  • Use a JavaScript script that does everything (see below)

Why? First of all because the JS code simplifies things. A lot. Second: Setting the name first to something that gets only close to the desired result and then modifying this name in a script introduces unnecessary steps. Without these Scan Name/Change Name actions, you don’t even need a regular expression at all (not that I mind REs, of course :wink: ). Just split Sortable Document Date/Weekday/Name Without Date at whitespace and mangle the 2nd element:

function performsmartrule(records) {
  records.forEach(r => {
    const nameParts = r.name().split(/\s+/);
    const weekday = nameParts[1].substring(0,3).toUpperCase();
    nameParts[1] = `(${weekday})`;
    r.name = nameParts.join(' ');
  })
}

For each record, this script

  • splits the name at whitespace and puts the parts in the array nameParts
  • For the 2nd element of this array, it puts the upper-cased first three letters in the variable weekday
  • It then replaces the 2nd element of nameParts with weekday in parentheses
  • Finally, it sets the name of the record to the elements of nameParts, joined with spaces

This code is a lot shorter than the AS equivalent, and it does more. No need for an external program like tr, either.

1 Like