Miscellaneous ExifTool related questions (and information)

Started by mpegleg, June 26, 2019, 07:38:14 AM

Previous topic - Next topic

Hayo Baan

Try this regexp: s/^([0-9]{4})-([0-9]{2})-([0-9]{2}) +([0-9]{4}).*/$1:$2:$3 $4:$5:00+08:00/
Hayo Baan – Photography
Web: www.hayobaan.nl

mpegleg

Thanks Hayo. That's close...

Result: 2018:11:07 1428::00+08:00

Just one of those ":" is out of place.
OS: Windows 11 Pro

mpegleg

...but I "think" I fixed it...

s/^([0-9]{4})-([0-9]{2})-([0-9]{2}) +([0-9]{2})+([0-9]{2}).*/$1:$2:$3 $4:$5$6:00+08:00

Is that right?

Now seems to give the correct result of: 2018:11:07 14:28:00+08:00

Thank you :)

..and I learnt a lot from studying your answer. Knowing about concatenating those multiple variables like that will be very useful to me.
OS: Windows 11 Pro

Hayo Baan

Sorry made a smal mistake, use s/^([0-9]{4})-([0-9]{2})-([0-9]{2}) +([0-9]{2})([0-9]{2}).*/$1:$2:$3 $4:$5:00+08:00/

Can you spot the difference ;)
Hayo Baan – Photography
Web: www.hayobaan.nl

mpegleg

Yes. I see what you did. You took away the extra "+" that I added, because then, there is no need for the extra variable $6 that I added.

Thank you :)
OS: Windows 11 Pro

mpegleg

OK. The following code now achieves what I want.   ie. It recovers and recreates the UTC CreateDates from the video filenames, when the filename has the format of "YYYY-MM-DD HHMM.mp4".

exiftool "-CreateDate<${filename; s/^([0-9]{4})-([0-9]{2})-([0-9]{2}) +([0-9]{2})([0-9]{2}).*/$1:$2:$3 $4:$5:00/}" -execute -CreateDate-=8 -common_args -r -api largefilesupport=1 -overwrite_original FILE/DIR


However this requires 2x runs, (to subtract 8 hours from my local time for UTC time) which is a bit of a drag, when there are thousands of video files.

Do you think there might be a better, more efficient way, to achieve this, which would only require one loop? ie. Get rid of the -execute. If it's not possible, then that's no major problem... I was just wondering if it may be possible?
OS: Windows 11 Pro

mpegleg

Aha. I found the solution:

exiftool "-CreateDate<${filename; s/^([0-9]{4})-([0-9]{2})-([0-9]{2}) +([0-9]{2})([0-9]{2}).*/$1:$2:$3 $4:$5:00/}" -api quicktimeutc -r -api largefilesupport=1 -overwrite_original FILE/DIR


the -api quicktimeutc solved the issue :)
OS: Windows 11 Pro

Hayo Baan

Excellent! If you're in a different time zone from where the video was taken, you can set the TZ environment variable to the correct value. exiftool will then convert using this time zone. (note: this works on Mac/Linux, not sure about Windows)
Hayo Baan – Photography
Web: www.hayobaan.nl

mpegleg

Hi. My regex ability is still very poor, esp. when converting into ExifTool Perl-like syntax. I've been trying for a little while to do the following...

Hopefully somebody might be able to provide some different examples, with full sample code to achieve the following simple requirement:

I would like to strip the very first character from the filename, and then rename itself to that new name, in the same directory.

In practice, I will be needing to strip a "." character from the beginning of the filename.

ie. abc.jpg becomes bc.jpg   -or-    .abc.jpg -> abc.jpg


Perhaps you could show me some examples using -filename, and/or also using substr, so that I can then choose what I consider the best method for my particular scenario, plus most importantly, learn from your examples.

Many thanks,
-Paul :)


OS: Windows 11 Pro

mpegleg

ok. So I worked out this,...

-filename<"${filename;~ s/^.//s}"

...but I couldn't get an equivalent "subst" function working. ??
OS: Windows 11 Pro

Phil Harvey

You should remove the "~".

Or with substr:

-filename<"${filename;$_ = substr($_, 1)}"

- 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 ($).

mpegleg

Quote from: Phil Harvey on July 26, 2019, 09:58:25 AM
You should remove the "~".  With substr:

- Phil

ah. ok. Done.

Thanks Phil.

Both are Perfect! :)
OS: Windows 11 Pro