rename video from "Media Created Date"

Started by Headlight, April 14, 2025, 11:23:35 PM

Previous topic - Next topic

Headlight

SG edit, split from older thread

I've just started using Tapo CCTV cameras and it produces weird file names. My normal renamer can't access the "Media Created Date" but Exiftool can so I thought I could use EXIFTool to rename my files using the Media Created dates.

In the above command:
"exiftool -api quicktimeutc -ext mov -ext mp4 -d "%Y%m%d_%H%M%S%%-c.%%le" "-filename<CreateDate" file.mp4"

I can't work out how to insert the filename to make it all work.

Here's an example filename: "17446265810621744558386710_0.mp4"

And here's one of the files:
https://drive.google.com/file/d/1Ls6-4qdSMYVm-mRpItBYyT0b1BjKulp1/view?usp=sharing

I would be very grateful if someone could point me in the correct direction to get EXIFTool to rename my file.

Thanks very much, Alwyn


StarGeek

I'm not sure what you're trying to do. The command you listed will rename the file to a "YearMonthDay_HourMinuteSecond" filename. Do you want to do something different? How does the original filename fit into this? Is there some format to that string of numbers?
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Headlight

Thanks SG, I had a heart attack when I saw my post had disappeared!  :D

QuoteThe command you listed will rename the file to a "YearMonthDay_HourMinuteSecond" filename. Do you want to do something different?
No. I want my filename to match that one.

My Tapo cameras produce a file in the form of the one on Google Drive. The filename is that long string of numbers (which I understand is some Unix code for the date, or something like that). Buried in the metadata of the file is the Media Create Date, which is identified by Exiftool (and shows up in the Windows Explorer window as "Date").

Currently, both the "Date Created" and the "Date Modified" are being changed to the date/time I import them to my PC, so I can't use those in my normal renaming program ("Renamer") because it doesn't read the Media Create Date.

What I'd like is for Exiftool to change the filename from that long string to the Media Create Date. I assume the code it would be something along the lines of the previous poster, but I can't work out how to actually use Exiftool to achieve the name change.

I dropped the MP4 onto the exe and it read out the metadata correctly, but nothing else.

Thanks for any help with this.


greybeard

Did you try the command in your original post with MediaCreateDate in place of CreateDate?

For example - for your sample file:

exiftool "-testName<MediaCreateDate" -d "%Y%m%d_%H%M%S%%-c.%%le" 17446265731041744559495782_0.mp4

Here I've used "testName" so that you can make sure the results are what you expect

Replace "testName" with "fileName" to actually make the name change

Headlight

Excellent, thanks Greybeard. Got it working. CL is not my forte!

I can see how the whole thing works now and will look into putting exiftool into the Windows path which i assume means you can run it anywhere. I'll also have a look for doing a whole folder at once.

I had a look at the Github on the GUI; would that make life easier for my scenario do you think?

Thanks again.

StarGeek

Quote from: Headlight on April 15, 2025, 06:48:15 AMNo. I want my filename to match that one.

The command works as written. Make sure you are using CMD, not PowerShell. PowerShell has different quoting rules compared to every other command line and many standard exiftool commands won't work. Examples
C:\>exiftool -progress -api quicktimeutc -ext mov -ext mp4 -d "%Y%m%d_%H%M%S%%-c.%%le" "-filename<CreateDate" Y:\!temp\x\y\17446265731041744559495782_0.mp4
======== Y:/!temp/x/y/17446265731041744559495782_0.mp4 [1/1]
'Y:/!temp/x/y/17446265731041744559495782_0.mp4' --> 'Y:/!temp/x/y/20250413_085252.mp4'
    1 image files updated

C:\>

Some things to take note of. Video times stamps are saved in UTC. The -api QuickTimeUTC option will adjust these time stamps to the local time when read. That is why the time stamp that is in the file, 2025:04:13 15:52:52, is changed to 2025:04:13 08:52:52 in my -07:00 time zone.

QuoteThe filename is that long string of numbers (which I understand is some Unix code for the date, or something like that).

Oh, I see it now. The number is too long for Unix time, so I dismissed that it would be a UNIX time, but it is two time stamps, one after the other.

1744559495782 = 2025-04-13 15:51:35.782 UTC
1744626573104 = 2025-04-14 10:29:33.104 UTC

QuoteBuried in the metadata of the file is the Media Create Date, which is identified by Exiftool (and shows up in the Windows Explorer window as "Date").

Yes. See the Windows Metadata thread for what tags are read to fill various Windows Properties.

QuoteCurrently, both the "Date Created" and the "Date Modified" are being changed to the date/time I import them to my PC, so I can't use those in my normal renaming program ("Renamer") because it doesn't read the Media Create Date.

Those are the file system time stamps. They are fragile and may not reflect the actual time stamp of a video.

You can fix those with a command like this. No need for scripting, just pass exiftool the directory the files are in, and it will process every file in it (add -r (-recurse) option to process subdirectories)
exiftool "-FileCreateDate<${CreateDate}+00:00" "-FileModifyDate<${CreateDate}+00:00" /path/to/files/
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

StarGeek

Quote from: Headlight on April 15, 2025, 10:47:55 AMI can see how the whole thing works now and will look into putting exiftool into the Windows path which i assume means you can run it anywhere.

You can try using Oliver Betz's exiftool installer, which I believe will add exiftool to the PATH automatically.

QuoteI'll also have a look for doing a whole folder at once.

You simply place any paths as part of the command line and exiftool will process them all. This can be multiple paths and individual filenames.  For example, this command would read all the files in c:\Pictures and e:\EvenMorePictures, as well as reading the single file.jpg
exiftool -DateTimeOriginal c:\Pictures D:\MorePictures\file.jpg e:\EvenMorePictures

It does not process subdirectories automatically. You can add the -r (-recurse) option to do this.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Headlight

Thanks SG, I tried setting the path in Windows Environment Variables but failed. I then tried Oliver's installer, and it worked; I can now use "exiftool" without putting in the full path, although I still had to put in the full path to the file itself. As for Oliver's install, it doesn't show up in the Program group, nor can I find exiftool.exe, so I need to put in the full path to the file I want to rename. I'm not actually sure what Oliver's EXE did/does.

I'm now trying to combine the filerenaming code with the +8 hours for my timezone but have failed. I can't work out what code from this:
Quoteexiftool "-FileCreateDate<${CreateDate}+00:00" "-FileModifyDate<${CreateDate}+00:00" /path/to/files/
I should put into into my renaming code to give me the +8 hours:
Quoteexiftool "-fileName<MediaCreateDate<" -d "%Y%m%d_%H%M%S%%-c.%%le" "D:\Technology\EXIF Tool\exiftool-13.27_64\17446265810621744558386710_0.mp4"

I tried adding "<${CreateDate}+08:00" after the "MediaCreateDate" but it didn't work. It popped up this message: "Warning: New file name not allowed in Windows (contains reserved characters) - D:/Technology/EXIF Tool/exiftool-13.27_64/17446265810621744558386710_0.mp4"




Phil Harvey

Is there any reason that you dropped the -api quicktimeutc option?  This will adjust CreateDate for MOV/MP4 videos to the local time zone.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Quote from: Headlight on April 15, 2025, 11:30:26 PMalthough I still had to put in the full path to the file itself.

Yes, you always have to put in a file path to the file unless you have CDed into the same directory as the file.

As for Oliver's install, it doesn't show up in the Program group, nor can I find exiftool.exe, so I need to put in the full path to the file I want to rename. I'm not actually sure what Oliver's EXE did/does.
I can't remember where, but it installs exiftool in an appropriate and security safe directory, depending upon if it is installed for all or for "just you". It's technically not installed the way a more complex program would be installed, and I don't believe anything is written to the registry as would probably be needed to have an uninstall process. I can be removed by simply deleting the "exiftool.exe" file and the "exiftool_files" directory.

There's a lengthy discussion of the whole creation process. The location is probably in there somewhere, but I couldn't find it with a quick search.

I'm now trying to combine the filerenaming code with the +8 hours for my timezone but have failed. I can't work out what code from this:
[quote]exiftool "-FileCreateDate<${CreateDate}+00:00" "-FileModifyDate<${CreateDate}+00:00" /path/to/files/[/quote]
I should put into into my renaming code to give me the +8 hours:
[quote]exiftool "-fileName<MediaCreateDate<" -d "%Y%m%d_%H%M%S%%-c.%%le" "D:\Technology\EXIF Tool\exiftool-13.27_64\17446265810621744558386710_0.mp4"[/quote]

I tried adding "<${CreateDate}+08:00" after the "MediaCreateDate" but it didn't work. It popped up this message: "Warning: New file name not allowed in Windows (contains reserved characters) - D:/Technology/EXIF Tool/exiftool-13.27_64/17446265810621744558386710_0.mp4"

I strongly suggest you use CreateDate insteadl of MediaCreateDate. CreateDate is the tag that Windows reads and there is a MediaCreateDate for each track (audio/video/subtitles/data) that is in the video, so you don't know which one you are reading. They should be the same, but you never know.

I had to edit the command because I had forgotten that you were using the -d (-dateFormat) option.

As Phil points out, the -api QuickTimeUTC option to make sure the time has been properly adjusted, otherwise you are using UTC as the filename, not your local time. Unless UTC is what you want to use.

exiftool -api QuickTimeUTC -d "%Y%m%d_%H%M%S%%-c.%%le" "-fileName<CreateDate" "-FileCreateDate<${CreateDate#}" "-FileModifyDate<${CreateDate#}" "D:\Technology\EXIF Tool\exiftool-13.27_64\17446265810621744558386710_0.mp4"


[/quote]
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype