How to interpret the timestamp in filename in downloaded files

Hi

I had to, one at a time :-(, to download 543 videos, not I need to be able to label to file names correctly.

i.e. the downloaded file from Ring:

1272036_6870141820246961153_stamp.mp4

How do I translate the filename to a proper yyyyMMddhhmmss name?

Thanks

Hey there, @MichaelGaarde. Although it sounds like you’ve already downloaded the files you need, this can be done automatically, on certain operating systems, with the Ring app. When downloading from an IOS mobile device or via web browser, these file names are not formatted. If you have an Android mobile device or a Mac OSX computer, downloading videos from the Ring app on these devices will automatically name the file with date/ time.

As we value our neighbours’ feedback, we’ve created a Feature Request board. If you see this as being useful on all platforms, feel free to request it there. This will allow other neighbors to comment and add interest, all in one place, so we can share it with our teams here. :slight_smile:

Hi,

I’d like to reiterate this question:

Your response explains options for downloading them. But I have *already* downloaded hundreds of videos, only to realize there’s no metadata at all, and the filenames seem to be random.

So, the original question is, how can we interpret the filenames? Are they some funky format taht we can interpret into the video’s original time and date?

I mean, Ring certainly knows how useless this is for archival/record-keeping to have hundreds of surveillance cam videos with no way to navigate them by time/date. Right?

1 Like

Hi Michael,
the translation is simple, just convert the 6870141820246961153 number to hexa, use eight MSB bytes, convert to decimal, multiply by 1000 and convert th result from system time to date time. Your downloaded file was recorder on Tue Sep 08 2020 15:39:02
Regards, Michael

4 Likes

For anyone still looking for this, I created a PowerShell Script to rename the files.

function Convert-RingNameToDate
{
  [CmdletBinding()]
  param
  (
    [Parameter(Mandatory=$true, Position=0, HelpMessage='Please add a help message here')]
    [System.Int64]
    $number
  )
  
  $bits = [Convert]::ToString($number,2)
  $MSB = [string]$bits[0..30] -replace(' ','')
  $Dec = [convert]::ToInt64($MSB,2)
  $Epoch = Get-Date -Date "01/01/1970"
  $DateTime = $Epoch.AddSeconds($Dec)
  
  return (Get-date ($DateTime) -Format YYYY-mm-dd-HH-mm-ss)
}


$Folder = "D:\Temp\Ring"
$Items = Get-ChildItem $Folder -Filter *.mp4 -Recurse

Foreach ($item in $Items){
  $newname = "$(Convert-RingNameToDate($item.BaseName)).mp4"
  if  (-not (Test-Path "$($item.DirectoryName)\$($newname)") ){
    $item | Rename-Item -NewName $newname
  }
}

To use:

Where I download the videos in a ZIP file, and they are named:
6946548309236321348.mp4

Change $Folder to the location of your Ring Video files.

You can modify the format of the filename from “yyyy-MM-dd-HH-mm-ss” to anything you like.
PowerShell date formatting

One more thing: I found the conversion to date/time was in UTC. If you wish to add or remove hours edit the line:

$DateTime = $Epoch.AddSeconds($Dec)
to
$DateTime = $Epoch.AddSeconds($Dec).AddHours(-5) # CST

2 Likes

Thanks for writing the Powershell script!
Only the format method was not correct.

return (Get-date ($DateTime) -Format “yyyy/MM/dd HH:mm K”)

And for who is interrested, I’ve converted the Powershell script to a Python3 version:

import datetime

def ConvertDingIdToDateTime(dingId):    
  bits = format(dingId, '0>42b')
  MSB = bits[0:31]
  dingDateTime = datetime.datetime.fromtimestamp(int(MSB,2))

  return dingDateTime
1 Like

WOW, but still sounds GREEK to me.

Why can’t Ring just make it easy on its users and rename all the files for us? Hate it when a company is NOT customer-centric/friendly

Yep it is a basic hiccup… and well meaning as some of the replies have been, there are not much use to a non-technical user -Scripts, Shells, Python, $$$ :slight_smile:

How do I request Ring do the conversion for us non-technical folk (I would think a MAJORITY of users are in this camp) so the videos are named something like:

20210715-201523.mp4 where the video was taken on July 15, 2021 at 8:15:23PM ?

AFAIK, Samsung smartphones and some cameras already name their files this way (or very similar).

1 Like

I’ve very recently discovered the filename issue. The day I need 80 videos that I can easily navigate the time each was taken, I find its just a string of numbers… I tried using the desktop app (I have an iMac) as I read this way of downloading files changes the filename to include a timestamp. But… you can only download one video at a time and if you have two videos taken within a minute it will only save one as the file name is the same. This is really annoying

I don’t suppose you have the full script for this? I cannot get it to work for me

The Windows 10 app does a excellent job of naming downloaded files [date-and-time]-where-motionORliveview ([2021-10-03T114708]-Upstairs-LiveView), I’m sure it is possible to get the same results from the browser download if the programmers were asked nicely, it really would keep the customer happy.

Sadly the Windows 10 App has it days numbered, it’s my main app for looking at my ring devices so I do nicely ask for it to be continued.

Thanks to @vorigeweek for the Python bit! Here’s a full script @Dan5ive. It’s insanely ugly but I was in a hurry to get something to work.

from os import listdir
from os.path import isfile, join
import datetime
import os

def ConvertDingIdToDateTime(dingId):    
  bits = format(dingId, '0>42b')
  MSB = bits[0:31]
  dingDateTime = datetime.datetime.fromtimestamp(int(MSB,2))

  return dingDateTime

# Make sure this path contains the videos you want to convert the filenames of
my_path = "C:/Ring/"

only_files = [f for f in listdir(my_path) if isfile(join(my_path, f))]

for f in only_files:
    # Just in case file name has already been converted
    if "stamp" in f:
        old_file_name = my_path + f
        # Assumes files are in this format: 71155064_7033625730319564493_stamp.mp4
        # Removes everything before the first underscore
        # Removes everything after the second underscore
        # Converts datetime to string in yyyy-mm-dd_hh_mm_ss format
        # Prepends path and appends .mp4 extension
        new_file_name = my_path + ConvertDingIdToDateTime(int(f.split('_', 1)[-1].split('_', 1)[0])).strftime("%Y-%m-%d_%H-%M-%S") + ".mp4"
        os.rename(old_file_name, new_file_name)

Hi there.

I just saw that the Ring Video file names are now in the form:
Ring_542010902_2123_7079275696466310081.mp4

Can you updated your PowerShell script to cater for this new format? Much thanks!

I could not get the script above to run, but will post the results on a separate post (to convert older videos using the older format of something like 7079275696466310081.mp4)

Workaround:
Use advancedrenamer.com and rename the file with replace method with this setting:
Text to be replaced: (.*)_(.*)_(.*)_(.*)
Replace with: \3_\4_stamp
Use regular expressions :white_check_mark:

Then apply the skript from above.

this script works fot the new filenames

function Convert-RingNameToDate
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true, Position=0, HelpMessage=‘Please add a help message here’)]
[System.Int64]
$number
)

$bits = [Convert]::ToString($number,2)
$MSB = [string]$bits[0…30] -replace(’ ‘,’’)
$Dec = [convert]::ToInt64($MSB,2)+3600
$Epoch = Get-Date -Date “01/01/1970”
$DateTime = $Epoch.AddSeconds($Dec)

return (Get-date ($DateTime) -Format “[yyyy-MM-ddTHHmmss]”)

}

$Folder = “c:\Ring”
$Items = Get-ChildItem $Folder -Filter *.mp4 -Recurse

Foreach ($item in $Items){
$result = $item.BaseName.substring(20, 19)
$newname = “$(Convert-RingNameToDate($result))-Front Door-Motion.mp4”
if (-not (Test-Path “$($item.DirectoryName)$($newname)”) ){
$item | Rename-Item -NewName $newname
}
}

I found that Ring now uses a couple of different formats for the filenames and so the scripts above do not always work.
Sometimes the number of characters in front of the timestamp number varies in length but the timestamp is always the last 19 digits of the filename.
So I have edited (some might say butchered) the script to account for this.

I also found that it doesn’t account for the Daylight Savings time change we have in Australia from October to March). So I have added some comments about the change required to account for this.

Here it is;

function Convert-RingNameToDate
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true, Position=0, HelpMessage=‘Please add a help message here’)]
[System.Int64]
$number
)

#Convert string filename to a number (seconds after Epoch)

$bits = [Convert]::ToString($number,2)
$MSB = [string]$bits[0…30] -replace(’ ‘,’')
$Dec = [convert]::ToInt64($MSB,2)
$Epoch = Get-Date -Date “01/01/1970”

Change AddHours value 10=AET (Apr-Sep) 11=AEST (Oct-Mar)

$DateTime = $Epoch.AddSeconds($Dec).AddHours(10)

return (Get-date ($DateTime) -Format “yyyy-MM-dd-HH-mm-ss”)
}

$Folder = “c:\Ring”
$Items = Get-ChildItem $Folder -Filter *.mp4 -Recurse

Foreach ($item in $Items){
$itemname = $item.Basename

New coding to remove Ring extra filename text

$length = $itemname.length
$itemna = $itemname.Substring($length-19,19)
$newname = “$(Convert-RingNameToDate($itemna)).mp4”
if (-not (Test-Path “$($item.DirectoryName)$($newname)”) ){
$item | Rename-Item -NewName $newname
}
}