Suggestion: modified date from clipboard?

Need to update modified date of binary files based on a date mentioned somewhere in accompanying separate text file. I may copy the date (yyyy-mm-dd) from the text file and wish I could paste it in Set Attribute.

Or is this already possible and am I overlooking that feature?

thanks.

SnagIt-17072022 071419

I don't know of an easy way to do it if the dates are in text format.

There are scripts to copy and paste dates from one set of files to another, but they use internal variables instead of the clipboard. They could be adapted to take the data from the clipboard, but don't work that way at the moment (at least the two that I can think of).

If it's just one file that needs updating, you could make a button to do that fairly easily, as long as the date/time are in the right format. But if it's just one file then it's even less time to type it by hand, unless it happens a lot. Taking a list of multiple file names and dates/times is what I'm thinking of.

With something like 2022-07-17 in the clipboard, SetAttr MODIFIED={clip} works fine.

1 Like

Many thanks.
Works nice, really!

That said, I agree and I am sorry:
it sound pretty much dissatisfied having to say that regretfully it seems to work for American style dates only.
Also looked at ClipboardEx (PASTEFROMCLIP/S), assuming this would use external clips, but I could not get that working.

Bad luck then.

Thanks again.

It works with YYYY-MM-DD or YYYYMMDD dates, not American ones.

If the dates are in a different format, some simple script code can fix that. Need to know which format to advise further.

Yes, sorry for the confusion, ahum. Indeed, not American style.
The format I am looking for is dd-mm-yyyy.
Vainly been searching for some alternative solution.

Here's the script in a button you can add to a toolbar:

For reference, this is the script code inside the button:

function OnClick(clickData)
{
	if (DOpus.GetClipFormat() != "text")
	{
		clickData.func.Dlg().Request("No text in clipboard.", "OK");
		return;
	}
	var strDateDMY = DOpus.GetClip("text");
	// DD-MM-YYYY -> YYYY-MM-DD
	var strDateYMD = strDateDMY.replace(/.*(\d\d)-(\d\d)-(\d\d\d\d).*/,"$3-$2-$1");
	if (strDateYMD == strDateDMY)
	{
		clickData.func.Dlg().Request("No DD-MM-YYYY date in clipboard.", "OK");
		return;
	}

	var cmd = clickData.func.command;
//	cmd.deselect = false; // Uncomment to prevent automatic deselection

	cmd.RunCommand('SetAttr MODIFIED="' + strDateYMD + '"');
}

Super!

Thank you very much indeed.
Works fine (as expected of course).
For me a real timesaver.
[Off-topic] Same goes the (quite) regularly used "Modify to Oldest" button.
Thread: "Copy timestamp based on oldest modified date within selection"

Thanks again!

1 Like