Unable to edit exif data related to date and time after google takeout

Started by nOne123, February 21, 2023, 08:47:42 AM

Previous topic - Next topic

nOne123

I want to edit EXIF data for these files names of images and videos.

I need solution for these 2 scenarios editing single File or Folder Directory.

1. I want to copy date, time with seconds from filename and paste it to "Date Taken" or "Media Created".
2. I want to copy date, time with seconds from "Date Modified" EXIF tag and paste it to "Date Taken" or "Media Created"

Types of files names from Google Takeout:

1. Screenshot_2022-09-21-17-01-01-545_com.android.chrome.jpg or Screenshot_2022-09-21-17-01-01-545***.jpg

2. IMG_20220921_170114***.jpg

3. IMG-20210329-WA0067.jpg (WhatsApp Image)

4. VID-20201112-WA0063.mp4 (WhatsApp Video)

5. 20191230_084945.mp4

After going through I tried these commands below -

exiftool -g1 -a -s
exiftool -P -overwrite_original "-AllDates<${filename;s/^[^-]*//} 00"
exiftool "-alldates<${filename;$_=substr($_,0,12)} 00:00:00"
exiftool -overwrite_original "-AllDates<${filename;$_=join ':',(/\d+/g)[2,1,0,3,4,5]} 00"
But sometimes its giving me errors like not writeable tags for multiple files at a time.
And sometimes it writes current date time for all files.
I am trying code one by one, it works for some files for some it won't.

StarGeek

Quote from: nOne123 on February 21, 2023, 08:47:42 AMBut sometimes its giving me errors like not writeable tags for multiple files at a time.
And sometimes it writes current date time for all files.

It helps significantly if you copy/paste the exact command and output (example) so we can see what's actually happening.

My first guess would be to ask what operating system you are using?  If you're using Mac/Linux/PowerShell, then you need to swap double/single quotes.

For What's App files, see this post.

For any file which contains the full 14 digits for the date/time and no leading numbers, then all you need to do is this (see FAQ #5).  This looks like it would cover your examples 1, 2, and 5.
exiftool "-AllDates<Filename" /path/to/files/

For videos, most video time stamps are supposed to be set to UTC and the program is supposed to adjust this to the local time zone when displayed (see 4th paragraph on the Quicktime tags page), with the most common exceptions being the Quicktime:CreationDate (not to be confused with the Quicktime:CreateDate) and the Quicktime:DateTimeOriginal.

If your computer is in the same time zone as where the video was shot, ignoring differences for Daylight/Summer time, then you can add the -api QuickTimeUTC option.  Otherwise, you either have to figure out the UTC yourself or use this -api option and include the correct time zone, e.g. "2023:02:03 04:05:06±07:00".
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

nOne123

While, searching I came accross these commands.
Can you explain these?
"-AllDates<${Filename;s/^[^-]*//}"
"-AllDates<${Filename;s/^[^-]*//} 00"
"-AllDates<${Filename;$_=substr($_,0,12)} 00:00:00"
"-AllDates<${Filename;$_=join ':',(/\d+/g)[2,1,0,3,4,5]} 00"
"-AllDates<${Filename;$_=substr($_,4,8);s/(\d{2})(\d{2})(\d{4})/$3:$2:$1/} 00:00"

I used these following commands after searching in this forum.
Some of them I understood so I written the meanings according to my understanding.
Please correct me about these commands.
Also need more info about "-wm w" commands

ExifTool Commands :-
ExifTool -g1 -a -s
ExifTool -g1 -a -s -AllDates

# For Images & Videos where Date & Time Tag is created but available in only 1 tag:
ExifTool -P -overwrite_original "-AllDates<FileModifyDate"
ExifTool -P -wm w -overwrite_original "-AllDates<FileModifyDate"

ExifTool -P -overwrite_original "-AllDates<ModifyDate"
ExifTool -P -wm w -overwrite_original "-AllDates<ModifyDate"

ExifTool -P -overwrite_original "-AllDates<CreateDate" 
ExifTool -P -wm w -overwrite_original "-AllDates<CreateDate"

ExifTool -P -overwrite_original "-AllDates<DateTimeOriginal"
ExifTool -P -wm w -overwrite_original "-AllDates<DateTimeOriginal"

# For Images & Videos where Date & Time Tag is not created but available in only 1 tag:
ExifTool -P -overwrite_original "-AllDates<FileModifyDate" -if "not $AllDates"
ExifTool -P -wm w -overwrite_original "-AllDates<FileModifyDate" -if "not $AllDates"

ExifTool -P -overwrite_original "-AllDates<ModifyDate" -if "not $AllDates"
ExifTool -P -wm w -overwrite_original "-AllDates<ModifyDate" -if "not $AllDates"

ExifTool -P -overwrite_original "-AllDates<CreateDate" -if "not $AllDates"
ExifTool -P -wm w -overwrite_original "-AllDates<CreateDate" -if "not $AllDates"

ExifTool -P -overwrite_original "-AllDates<DateTimeOriginal" -if "not $AllDates"
ExifTool -P -wm w -overwrite_original "-AllDates<DateTimeOriginal" -if "not $AllDates"

# For Images & Videos where date and time is present in Filename:
ExifTool -P -overwrite_original "-AllDates<Filename"
ExifTool -P -wm w -overwrite_original "-AllDates<Filename"

ExifTool -P -overwrite_original "-AllDates<${Filename;$_=substr($_,0,12)} 00:00:00"
ExifTool -P -wm w -overwrite_original "-AllDates<${Filename;$_=substr($_,0,12)} 00:00:00"

# For Images & Videos - Date & Time Tag is not created but available in Filename:
ExifTool -P -overwrite_original "-AllDates<Filename" -if "not $AllDates"
ExifTool -P -wm w -overwrite_original "-AllDates<Filename" -if "not $AllDates"

ExifTool -P -overwrite_original "-AllDates<${Filename;$_=substr($_,0,12)} 00:00:00" -if "not $AllDates"
ExifTool -P -wm w -overwrite_original "-AllDates<${Filename;$_=substr($_,0,12)} 00:00:00" -if "not $AllDates"

# For Videos: -api QuickTimeUTC (I avoid this tag because need to adjust time according to 0.00 UTC time before adding)
ExifTool -P -wm w -overwrite_original -Time:All="2014:01:26 00:00:00"

ExifTool -overwrite_original "-Quicktime:Time:All#<DateTimeOriginal"
ExifTool -P -overwrite_original "-Quicktime:Time:All#<DateTimeOriginal"
ExifTool -P -wm w -overwrite_original "-Quicktime:Time:All#<DateTimeOriginal"

ExifTool -P -overwrite_original "-Quicktime:Time:All#<$Filename"
ExifTool -P -wm w -overwrite_original "-Quicktime:Time:All#<$Filename"

ExifTool -P -overwrite_original "-Quicktime:Time:All#<$FileModifyDate"
ExifTool -P -wm w -overwrite_original "-Quicktime:Time:All#<$FileModifyDate"

ExifTool -P -overwrite_original "-Quicktime:Time:All#<$ModifyDate"
ExifTool -P -wm w -overwrite_original "-Quicktime:Time:All#<$ModifyDate"

# For MKV, MPG, WMV & more Videos: I used Attribute Changer - https://www.petges.lu

But this software only changed video File attributes not changed any video tags.
==================================================
# For MKV Videos: How to Edit MKV Metadata in MKVToolNix - https://mkvtoolnix.download/downloads.html

Step 1. Download MKVToolNix and open it.

Step 2. Hit the "Header Editor", choose the "Open Matroska or WebM file" option to browse and open the original MKV file that you want to edit the metadata. This section will be populated with all the video, audio, subtitle and other such header information. It can be expanded by clicking on the plus symbols.

Step 3. To edit a particular header field, drill down to it and click on it. The right side of the GUI will show its current value. You can add, remove or edit the default values.

Step 4. After you are done, we need to make sure that the resulting header is valid. To check this choose from above Header editor → Validate values.

Step 5. If validation passes, choose from above Header editor > Save.
==================================================
# For MPG, WMV & more Videos:

Step 1. Open MKVToolNix

Step 2. Hit the "Multiplexer", close the current tab, drag and drop your desired video file type which you want to convert to MKV.

Step 3. On the bottom you will click on "Start multiplexing".

Step 4. After successful multiplexing you will have your converted file.

Step 5. Hit the "Header Editor", choose the "Open Matroska or WebM file" option to browse and open the original MKV file that you want to edit the metadata. This section will be populated with all the video, audio, subtitle and other such header information. It can be expanded by clicking on the plus symbols.

Step 6. To edit a particular header field, drill down to it and click on it. The right side of the GUI will show its current value. You can add, remove or edit the default values.

Step 7. After you are done, we need to make sure that the resulting header is valid. To check this choose from above Header editor → Validate values.

Step 8. If validation passes, choose from above Header editor > Save.

StarGeek

Quote from: nOne123 on February 26, 2023, 12:28:56 AMWhile, searching I came accross these commands.
Can you explain these?
"-AllDates<${Filename;s/^[^-]*//}"
"-AllDates<${Filename;s/^[^-]*//} 00"
"-AllDates<${Filename;$_=substr($_,0,12)} 00:00:00"
"-AllDates<${Filename;$_=join ':',(/\d+/g)[2,1,0,3,4,5]} 00"
"-AllDates<${Filename;$_=substr($_,4,8);s/(\d{2})(\d{2})(\d{4})/$3:$2:$1/} 00:00"

I used these following commands after searching in this forum.
Some of them I understood so I written the meanings according to my understanding.

I would ignore these for the most part.  These are all very specific situations where the filename includes numbers other than the date/time numbers.  Extra numbers, especially leading numbers, need to be stripped away.

"-AllDates<${Filename;s/^[^-]*//}"
This strips away all leading characters up to the first hypen. So this assumes that the correct date time starts after the hypen.

"-AllDates<${Filename;s/^[^-]*//} 00"
This is the same, except it adds 00 to the end.  This would correct a filename that has leading numbers before the hyphen and no seconds value afterwards e.g. YearMonthDateHourMinute

"-AllDates<${Filename;$_=substr($_,0,12)} 00:00:00"
This one would be for files that start with YearMonthDay.  It extracts the first 12 characters of the file and adds 0s for the hours/minutes/seconds.

"-AllDates<${Filename;$_=join ':',(/\d+/g)[2,1,0,3,4,5]} 00"
This one is complex and very specific.  It grabs 6 groups of numbers from the filename.  The sequence of 2,1,0 indicates that the filename would be something like Day-Month-Year.  The following number groups would be HourMinuteSecond in the correct order.  I'm not sure why there is a trailing 00 since the command already extracts a seconds value from the filename.

"-AllDates<${Filename;$_=substr($_,4,8);s/(\d{2})(\d{2})(\d{4})/$3:$2:$1/} 00:00"
This one is more complex than it needs to be.  First, starting at the 5th character (substr starts counting from 0, i.e. first character is 0, second character is 1, etc) it extracts the next 8 characters.  Then it rearranges them from DayMonthYear into YearMonthDay.  It then adds 00 for hours and minutes.  It probably should have a 00 for seconds, but I think exiftool will take the last two 0s and 0 Minutes and 0 Seconds.

QuoteAlso need more info about "-wm w" commands

See the -wm (-writeMode) option.  The w option there is "Write existing tags".  So it will not create any new tags, only update existing tags.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

nOne123

#4
Thank you.
I successfully edited all photos and videos around 50k.
Thank you again.
This tool is great.