Copy file name as .txt - add shooting date

I have the following button:

filetype new .txt newname "norename:{file|noext}.txt"

Resulting in:


Is there a way to expand this so it will shooting date?

As a long shot I tried:

filetype new .txt newname "norename:{file|noext}{shootingtime|D#yyyyMMdd}.txt"

but that didn't work.


Download this and drag it to your toolbar while in Customize mode:

New .TXT Shooting Date.dcf (1.8 KB)

For reference, here's the script code inside it:

function OnClick(clickData)
	var cmd = clickData.func.command;

	for (var eSel = new Enumerator(clickData.func.sourcetab.selected); !eSel.atEnd(); eSel.moveNext())
		var item = eSel.item();
		if (!item.is_dir)
			var newName = item.name_stem_m;
			var imageMeta = item.metadata.image;
			if (imageMeta != null)
				var dateTaken = imageMeta.datetaken;
				if (dateTaken != null)
					newName += dateTaken.Format('D#yyyyMMdd');

			var cmdLine = 'FileType NEW=".txt" NEWNAME="norename:' + newName + '.txt"';

Waow, many thanks.

One last thing, would it be possible to add a space between file name and date?

Right now this is the situation:
DSC00146.JPG te become

If possible the new name would read:
DSC00146 20150429.txt

So I can re-date the file after date in file name, for which action I have a separate button.


					newName += dateTaken.Format('D#yyyyMMdd');


					newName += " " + dateTaken.Format('D#yyyyMMdd');

Thank you very much.
Had no clue where and how to add the space myself.