Hi! I'm trying to auto-edit the created date of all my video files in my Video Editing resource library. I am trying to match the date to any year listed in the title.
For example:
'(2s) John Cena Entrance 2023 IR.mp4' should apply the date 01/01/2023 (January 1st 2023) with the time 00:00.
However what is actually happening is that it is setting it to 01/04/2023 (April 1st 2023) with the time 01:00.
Here is my batch script:
@echo off
REM Set the ExifTool path
set EXIFTOOL_PATH=exiftool.exe
REM Loop through each MP4 file in the current directory
for %%F in (*.mp4) do (
REM Extract year from filename using a regular expression
for /f "tokens=2 delims=()" %%Y in ("%%F") do (
REM Set year to be the extracted year
set year=%%Y
REM Apply the year to FileCreateDate
"%EXIFTOOL_PATH%" -System:FileCreateDate="%%Y:01:01 00:00:00" "%%F"
echo Updated: %%F with year %%Y
)
)
REM Done, pause to show the result
echo All files have been updated!
pause
Also, with my alt files of a similar clip, I have named them with a 2 at the end. (For example '(2s) Kevin Owens Entrance 2022 IR 2').
However this is setting the date to 04/02/2022 (February 2nd 2022) at 01:01. Please could I get some assistance in forcing this to be the January 1st date at midnight too!
I am using the latest version of ExifTool.
Thank you kindly if you have the time to help me.
Windows bat files aren't my strong suit, but doing some testing on the central loop, this is what the final exiftool command looks like
exiftool -System:FileCreateDate=" John Cena Entrance 2023 IR.mp4:01:01 00:00:00" "%F"Obviously, all that text can't actually be part of a file date. But exiftool is flexible when writing date/time values.
From FAQ #5, How do I format date and time information for writing (https://exiftool.org/faq.html#Q5)
QuoteHaving said this, ExifTool is very flexible about the actual format of input date/time values when writing, and will attempt to reformat any values into the standard format unless the -n option is used. Any separators may be used (or in fact, none at all).
You are parsing the filename to remove the leading "(2s)", which leaves "John Cena Entrance 2023 IR.mp4". Exiftool then takes all the numbers from that to start forming the time stamp. Notices that this
includes the 4 from the extension, leading to a value of "2023:4:01 01:00:00".
An additional problem is that you are looping exiftool. Exiftool's biggest performance hit is the startup time, which means that this will take much longer than using exiftool's built-in batch ability (see Common Mistake #3, "Over-scripting" (https://exiftool.org/mistakes.html#M3))
Try this command.
exiftool -ext mp4 "-FileCreateDate<${Filename;$_=(m/(\d{4})/)?$1:undef;}:01:01 00:00:00" /path/to/files/What this command does is take the
Filename and tries to match four numbers. This number is captured and the value of the tag
Filename is changed to that number (this does not change the actual name of the file). The value of that number plus the rest of the time stamp is then used to set the
FileCreateDate. If the file does not have four numbers that can be used as a year, it will throw two warnings and skip that file
Warning: [minor] Advanced formatting expression returned undef for 'Filename'
Warning: No writable tags set from
These can be ignored
You would replace
/path/to/files/ with the directory that you want to process. You can list multiple directories and individual files combined. For example, you could list this
"C:\Users\NAME\Pictures\My photo albums" D:\videos\MyVideo.mp4and exiftool will process all the files in "My photo albums" as well as the single file "MyVideo.mp4"
The
-ext (
-extension) option (https://exiftool.org/exiftool_pod.html#ext-EXT---ext-EXT--extension) is used to make sure only MP4 files are processed.
Quote from: Phil Harvey on March 06, 2025, 10:19:23 AMI will delete this duplicate post.
See here to respond (https://exiftool.org/forum/index.php?topic=17153.0)
Maybe delete the other post since I went to all this work :D