ExifTool Forum

ExifTool => Newbies => Topic started by: cavallino on April 23, 2025, 04:10:17 PM

Title: Set the ModifyDate of WhatsApp Videos by Filename (date in filename but no time)
Post by: cavallino on April 23, 2025, 04:10:17 PM
Hi,
sorry for asking this but I could not find a simple solution and the search function of the forum does not work. The solutions I found are too complex, to many ifs and special cases, so, I do not know what I am doing...

I have filenames like this from Whatsapp downloads:
VID-YYYYMMDD-WAnnnn.mp4 where nnnn is a running file number and YYYYMMDD are the date I want to set as FileModifyDate
eg: VID-20240331-WA9876.mp4

This command almost does the job, however, it uses the first 14 digits it finds (but there are only 8 useful digits, nnnn can result in invalid results and the date will not be set because of an error):

exiftool "-FileModifyDate<Filename" d:\test -overwrite_original

Can somebody pls. help to get this right?

A pseudocode solution would be:
filename=left(filename,12)+'000000' or in words
take the first 12 characters of the filename and add 000000 instead of "Filename", the command would then calculate the FileModifyDate from "VID-20240331000000"

I have no idea what the code for this should look like. Pls. help :)

Best regards
arno

PS:
If somebody is interested:
When moving fotos and videos from GoogleDrive to OneDrive including Whatsapp media I found two major problems:
The modification date of the files changes to the timestamp when files are copyied. Whatsapp files do not have any Exif information. The solution for the first case and photos from Whatsapp is to use the software "Exif Date changer" to set modification date from recording date and use the filename if there is no recording date. However, only the commercial license works with videos... The solution for Whatsapp Videos is my question above.

Title: Re: Set the ModifyDate of WhatsApp Videos by Filename (date in filename but no time)
Post by: StarGeek on April 23, 2025, 08:43:30 PM
When the search feature isn't availble due to server stress, you can always use Google with the site: keyword. For example
site:exiftool.org whatsapp (https://www.google.com/search?udm=14&q=site:exiftool.org%20whatsapp)

See this post (https://exiftool.org/forum/index.php?topic=11997.msg64777#msg64777) for an example command. All you would need to do is replace AllDates with FileModifyDate

If you're on Windows, use CMD, not PowerShell. If you're on Mac/Linux, change the double quotes into single quotes.
Title: Re: Set the ModifyDate of WhatsApp Videos by Filename (date in filename but no time)
Post by: cavallino on April 24, 2025, 05:06:14 AM
Thanks a lot!

The requested solution is:
exiftool "-FileModifyDate<${Filename;m/(\d{8})/;$_=$1} 000000}" d:\test -overwrite_original
To set the file modify date and the file create date I use this (paused syncing OneDrive for better speed):
exiftool "-FileModifyDate<${Filename;m/(\d{8})/;$_=$1} 000000}" "-FileCreateDate<${Filename;m/(\d{8})/;$_=$1} 000000}" d:\test -overwrite_original


PS:
I got this warning for three files, the date was set correctly and I see no problem and no difference to other files:
Warning: Unknown trailer with truncated '\x14\x10\x00\x00' data at offset 0x453749 - D:/mypath/VID-20231107-WA0011.mp4(Using CMD in Win11, exiftool-13.27_64)
Title: Re: Set the ModifyDate of WhatsApp Videos by Filename (date in filename but no time)
Post by: StarGeek on April 24, 2025, 10:52:07 AM
I haven't seen WhatsApp files that had a response like that before. Strange.

But you don't need to worry about it. When writing only file system data, like FileCreateDate/FileModifyDate, exiftool doesn't edit the file at all, just edits the file system data. So the file itself is untouched and hasn't been changed.

The -overwrite_original option (https://exiftool.org/exiftool_pod.html#overwrite_original) isn't needed for this command since the file hasn't been changed. You can drop it if you like, but it won't otherwise affect the command.
Title: Re: Set the ModifyDate of WhatsApp Videos by Filename (date in filename but no time)
Post by: cavallino on April 25, 2025, 09:40:47 AM
Ok, thank you!