Convert Epochtime stamp to date


I use a program to download tiktok videos, but the program saves the files in a useless way. It uses the username_Epoch Unix Timestamp_random numbers.mp4. While I can go to online to convert it, simply looking at it means nothing to me.

Is there a way to convert the time to a normal time and change the created or modified date stamp to reflect the actual date? That way I can sort the folder by the latest file. I have no experience in scripting, so not sure if that would be the only way to do this or not.

Sample: USERNAME_1629470841_6998523966335765762.mp4


Yes, you can do this with a script. Here's a simple button that will do it using a small bit of JScript code.

Download the .dcf file and add it to your toolbars in Customize mode. Then select one or more of the TikTok video files and click it to fix their datestamps.

Fix TikTok Dates.dcf (1.5 KB)

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

function OnClick(clickData)
	var re = new RegExp('.*_([0-9]*)_[0-9]*\.mp4');
	for (var eSel = new Enumerator(clickData.func.sourcetab.selected); !eSel.atEnd(); eSel.moveNext())
		var match = re.exec(eSel.item().name);
		if (match.length == 2)
			var date = new Date(1000 * match[1]);
			var strDate = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " +
						  date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
			var strCmd = 'SetAttr FILE="' + eSel.item().realpath + '" CREATED="' + strDate + '" MODIFIED="' + strDate + '"';