MP4 createdate from filename wth -2h shift

Started by DeltaTango, December 20, 2023, 02:48:33 PM

Previous topic - Next topic

DeltaTango

Hi,

my videos have following format: VID_20230718_094416.mp4

how can I set the createdate Tag with an shift of -2 hours?

I have tried this, but it don't work:
-api LargeFileSupport=1 -*createdate<${filename}-02:00

Unfortunately it takes a long time to write the whole >20GB files once more. Is there any faster way?

Screenshot 2023-12-20 204618.png

StarGeek

While exiftool can be flexible about writing a time stamp from a filename, it still isn't formatted properly to actually shift the time.

exiftool -api LargeFileSupport=1 "-*createdate<${filename;s/.*(\d{4})(\d\d)(\d\d)_(\d\d)(\d\d)(\d\d).*/$1:$2:$3 $4:$5:$6/;ShiftTime('-02:00')}" VID_20230718_094416.mp4

This uses Regular Expression (RegEx) to match the date/time values and add the colons and space in the correct locations.  It the calls the ShiftTime helper function to shift the time.  If you're using Mac/Linux, then change the double quotes to single quotes.

Quote from: DeltaTango on December 20, 2023, 02:48:33 PMUnfortunately it takes a long time to write the whole >20GB files once more. Is there any faster way?

No. Exiftool has to rewrite the entire file. See FAQ #31.
"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

DeltaTango

Quote from: StarGeek on December 20, 2023, 09:15:03 PMs/.*(\d{4})(\d\d)(\d\d)_(\d\d)(\d\d)(\d\d).*/$1:$2:$3 $4:$5:$6/

puuh this look not simple - is there any explanation of this

StarGeek

RegEx isn't simple and is too complex to teach in these forums.  There are lots of tutorial websites on the subject.

In this case, this is a RegEx substitution. Breaking it down
s/ start of the substation. The basic details for a RegEx substitution is s/Search/Replace/.  Everything between the first two slashes is replaced by whats between the last two. But there are a lot of options.
.*  The dot stands for any single character.  The asterisk means 0 or more of the previous character.  The attempts to grab all the leading characters in the filename. These characters will not be saved
(\d{4}) The parenthesis means the value between them will be captured and saved for later use. The \d stands for any single digit (0-9) and the {4} means that the previous character is repeated four times.  The result is that the next four digits (the year) are saved and will be saved in the $1 variable.
(\d\d)  This captures and saves two digits.  This is repeated multiple times in the rest of the text, capturing the Month, Day, Hour, Minutes, and Seconds.  These will be saved in variables $2 through $6.
.* same as the first copy.  This is used to throw away everything after the last important number.
This search term ends with the slash and the replace starts after that.
$1:$2:$3 $4:$5:$6 This is where the six previous captures are reformatted into a standard date/time.

On Regex101.com, you can look at this RegEx in more detail.  The upper right corner of this page gives a step-by-step breakdown of the command.
"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

DeltaTango

Many thanks for this excellent explanation!! :)  Hopefully this will help me when the filename looks different  :D