Transforming dates?

I have a whole batch of drafts, maybe 300, which start with a manual date, what I mean is I typed the date in on each draft when I created it. (doh). Anyway, I’d like to transform the date so they are all the same format.
At present they are in the format:- (some notes may be d-m-yy or dd-m-yyy etc etc)


I’d like them to read



I don’t mind selecting the text in each draft and hitting a key combo or pressing an action, or is there a better way I can achieve this on a Mac ?


I think this action should work. Try it on a selection of drafts one by one and check the results. Revert using version history if you find an issue. Once you are satisfied it works as expected, select all the drafts you want it to run against and run the action to batch process all of the selected drafts,

The action uses a single script step with the following code.

let astrTitle = draft.title.split(" ");
let strDate = astrTitle[0];
//Only process if it looks like we have a date
if ((strDate.match(/\//g) || []).length == 2)
	//Build the new date
	let astrDate = strDate.split("/");
	let strDay = ("0" + astrDate[0]).slice(-2);
	let strMonth = ("0" + astrDate[1]).slice(-2);
	let strYear = ("20" + astrDate[2]).slice(-4);
	//Rebuild and replace the draft title
	let astrContent = draft.lines;
	astrTitle[0] = strYear + "-" + strMonth + "-" + strDay;
	astrContent[0] = astrTitle.join(" ");
	draft.content = astrContent.join("\n");

This should work on Mac, iPad and iPhone, though the way you run an action against a batch of drafts can vary a little by platform and if you are using pointing devices, keyboard access, etc. But you could certainly run this action against all of your batch of 300 drafts in one shot rather than selecting each one at a time to run it.

See Select & Operations.

Hope that helps.


Hey thanks! I tried this but the action doesn’t seem to run or at least it does nothing.
I created a test draft and tried double clicking the action but nothing.

Ahh, sorry my bad. I realise the draft has to start with the date.
Is it a lot of work to change it to look for the date in the first line?

Dream 21/03/20
Dream 21/3/20


That was exactly how you described it…


That depends.

Your new example titles end with a date, so rather than checking the start of the line, we could check the end of the line.

However, your request is now to look for the date in the first line.

Where can the date appear in your first line? Only at the end, or anywhere in the line?

1 Like

I think at the end of the first line will be fine, I’ve just checked most of them.

In that case we just need to change the two title array references from the first element to the last element.


Awesome., thanks for your help with this.