Epoch time rename

Arlo cameras, and probably others, create video files that have the "epoch date" as their name.

For example: 1573903271899.mp4

There are websites that can convert the epoch date into human friendly dates:

Epoch Converter - Unix Timestamp Converter

But this seems like the sport of thing that can be automated in DOpus.

I have done a quick search around here and found a few messages about epoch dates. But nothing on renaming with the.

Am I barking up the wrong tree in thinking that this should be possible?

You can use JScript for that:

Edit: See wysocki's reply below for an improved version

function OnGetNewName(getNewNameData)
{
	var epochTime = parseInt(getNewNameData.item.name_stem_m);
	var date = new Date(epochTime);

	var y = zeroPad(date.getFullYear(), 4);
	var m = zeroPad(date.getMonth(), 2); // BUG: See wysocki's reply below
	var d = zeroPad(date.getDay(), 2);   // BUG: See wysocki's reply below

	var n = y + "-" + m + "-" + d + getNewNameData.item.ext_m;

	return n;
}

function zeroPad( number, digits )
{
	var numStr = number.toString()
	var width = digits - numStr.length;
	while (width > 0)
	{
		numStr = "0" + numStr;
		width = width - 1;
	}
	return numStr; // always return a string
}

Excellent.

I'll see if I can built on that to add the time.

Request for this thing comes up regularly on the Arlo support forum. It would be good to be able to throw a "use DoPus" message at them.

Apparently, a datestamp is needed when people try to get the police interested in videos of criminal activities.

1 Like

Great! I also needed this to convert the epoch time from Arlo security cameras. And I've modified the script here to also include the time. PLUS, I fixed a couple of errors in the script by adding 1 to the month number and using getDate instead of getDay (day of the month instead of day of the week)!
Can't believe I got to correct Leo's work!!!

function OnGetNewName(getNewNameData)
{
	var epochTime = parseInt(getNewNameData.item.name_stem_m);
	var date = new Date(epochTime);
	var y = zeroPad(date.getFullYear(), 4);
	var m = zeroPad(date.getMonth() + 1, 2);
	var d = zeroPad(date.getDate(), 2);
	var h = zeroPad(date.getHours(), 2);
	var mi = zeroPad(date.getMinutes(), 2);
	var s = zeroPad(date.getSeconds(), 2);
	var n = y + "-" + m + "-" + d + " " + h + "." + mi + "." + s + getNewNameData.item.ext_m;
	return n;
}

function zeroPad( number, digits )
{
	var numStr = number.toString()
	var width = digits - numStr.length;
	while (width > 0)
	{
		numStr = "0" + numStr;
		width = width - 1;
	}
	return numStr; // always return a string
}
1 Like