Photos: Sequentially Set Date Taken, Digitized, Created and Modified

This script does that, starting with the current date and adding one day per file.

// https://resource.dopus.com/t/photos-sequentially-set-date-taken-digitized-created-and-modified/43090

// 2022-12-08

function OnClick(clickData) {
    var cmd = clickData.func.command;
    var tab = clickData.func.sourcetab;
    cmd.deselect = false;

    var currDate = DOpus.Create().Date();

    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {
        var item = e.item();
        var str = currDate.Format('D#yyyy-MM-dd T#HH:mm:ss');
        cmd.RunCommand('SetAttr FILE="' + item + '" META "createdate:' + str + '" "datedigitized:' + str + '" "datetaken:' + str + '" "lastmodifieddate:' + str + '"');
        currDate.Add(1, 'd');
    }
}
Button as XML
<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" textcol="none">
	<label>43090</label>
	<icon1>#newcommand</icon1>
	<function type="script">
		<instruction>@script JScript</instruction>
		<instruction>// https://resource.dopus.com/t/photos-sequentially-set-date-taken-digitized-created-and-modified/43090</instruction>
		<instruction />
		<instruction>// 2022-12-08</instruction>
		<instruction />
		<instruction>function OnClick(clickData) {</instruction>
		<instruction>    var cmd = clickData.func.command;</instruction>
		<instruction>    var tab = clickData.func.sourcetab;</instruction>
		<instruction>    cmd.deselect = false;</instruction>
		<instruction />
		<instruction>    var currDate = DOpus.Create().Date();</instruction>
		<instruction />
		<instruction>    for (var e = new Enumerator(tab.selected_files); !e.atEnd(); e.moveNext()) {</instruction>
		<instruction>        var item = e.item();</instruction>
		<instruction>        var str = currDate.Format(&apos;D#yyyy-MM-dd T#HH:mm:ss&apos;);</instruction>
		<instruction>        cmd.RunCommand(&apos;SetAttr FILE=&quot;&apos; + item + &apos;&quot; META &quot;createdate:&apos; + str + &apos;&quot; &quot;datedigitized:&apos; + str + &apos;&quot; &quot;datetaken:&apos; + str + &apos;&quot; &quot;lastmodifieddate:&apos; + str + &apos;&quot;&apos;);</instruction>
		<instruction>        currDate.Add(1, &apos;d&apos;);</instruction>
		<instruction>    }</instruction>
		<instruction>}</instruction>
	</function>
</button>
4 Likes