Macro to prepend YYYYMMDD

I save files daily and I need to append to the file name as the first characters the present year and date in this form 20260126 for the year 2026, January the 26th. Is there such a macro or any ideas how to do this? aka YYYMMDD_myfilename. I don’t care about the path because the path/directory will already be active in the file save as dialog box and I want to activate the macro to pre-append the YYYMMDD_myfilename.

Thanks!

I have one that does exactly that. I’ll send it over when I get home. Cheers.

Keith

1 Like

Hi, welcome.

(Prepend, at the start. :slight_smile: )

The ICUDateTime token is what you need here (see also Dates and Times). The format to get what you want here is: %ICUDateTime%yyyyMMdd%.

For improved readability, I prefer to use %ICUDateTime%yyyy–MM–dd%, which today gives the result “2026-04-13”. I mention that just as an option.

So you could just position the cursor at the start of the filename and then trigger a macro that contains an action to insert the string that is produced by the %ICUDateTime% token. You could use either an Insert text by pasting action (this would normally be the better choice) or an Insert text by typing action.

You might perhaps then want to place the cursor automatically or improve your macro in other ways, but the %ICUDateTime% token is the key part.

3 Likes

Thank you so much!! That worked perfectly!

3 Likes

Hi @TrukMeister. If you are also commonly enclosing files in new folders, you might find a macro I recently shared useful:

I often create folders named (or prefixed with) YYYY-MM-DD. The macro contain a setting that allow you to easily change that to YYYYMMDD format.

1 Like

YYYYMMDD_

Screen shot

ISOyyyymmdd_prepend.kmmacros (3.3 KB)

YYYYMMDD-Day of week_

Screen shot

ISOyyyymmdd-EEEE_prepend.kmmacros (3.4 KB)


I disabled the macros before exporting and importing.
You'll have to enable the macros after importing.

I started myself with YYYY-MM-DD. After a while I added the day of the week.


Cheers

Keith

Macros are automatically imported disabled unless you hold down the option key while importing.

3 Likes