Main Menu

Image date fix

Started by EvilZoid, September 01, 2024, 05:08:21 AM

Previous topic - Next topic

EvilZoid

I have a lot of pictures and videos, but their modified and created dates are incorrect. Is there a way to retrieve the original creation date and time from the media metadata (e.g., the "date taken" for images and the "media created" metadata for videos) and update the modified and created dates accordingly? I understand that some images might not have this information, so I'd like to move those files to a separate folder for manual correction.

Additionally, I downloaded these files from Google Photos, and each one has a corresponding JSON file that includes the correct dates, like this:

{
  "title": "2021-04-11_07.43.00_2.png",
  "description": "",
  "imageViews": "0",
  "creationTime": {
    "timestamp": "1633915932",
    "formatted": "Oct 11, 2021, 1:32:12 AM UTC"
  },
  "photoTakenTime": {
    "timestamp": "1628320524",
    "formatted": "Aug 7, 2021, 7:15:24 AM UTC"
  },
  ...
}
If possible, I would like to update the file timestamps using the dates from the JSON files.

StarGeek

Quote from: EvilZoid on September 01, 2024, 05:08:21 AMI have a lot of pictures and videos, but their modified and created dates are incorrect. Is there a way to retrieve the original creation date and time from the media metadata (e.g., the "date taken" for images and the "media created" metadata for videos) and update the modified and created dates accordingly? I understand that some images might not have this information, so I'd like to move those files to a separate folder for manual correction.

These commands are for Windows CMD. You didn't mention your OS, so if it is Mac/Linux, you need to change the double quotes into single quotes and vice versa.

The first thing to do would be to separate the ones with no embedded timestamps. The reason you have to do this first is because videos will always have a CreateDate, but if the date isn't known, it will be set to all 0s.
exiftool -if "(not $CreateDate or $CreateDate='0000:00:00 00:00:00') and not $DateTimeOriginal" -Directory=/path/to/NoDates/ /path/to/files/

The command to set the file system time stamps would be something like this. It will use the two most common embedded timestamps to set the file system ones.
exiftool -api QuickTimeUTC "-FileModifyDate<CreateDate" "-FileCreateDate<CreateDate" "-FileModifyDate<DateTimeOriginal" "-FileCreateDate<DateTimeOriginal" /path/to/files/

Many of the files that don't have an embedded date, such as screenshots, often have the date as the filename. If so, you can directly copy the date from the filename like this
exiftool -api QuickTimeUTC "-FileCreateDate<Filename" "-FileModifyDate<Filename" "-CreateDate<Filename" "-DateTimeOriginal<Filename" /path/to/files/

If some of the files are from WhatsApp, those have the date in the filename, but not the time. Search these forums for the command for this.

These commands create backup files.  Add -Overwrite_Original to suppress the creation of backup files.  Add -r to recurse into subdirectories.

* 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).

EvilZoid

I will check and let you know, and I have windows 10, will process, mp4, mkv, png, jpeg, jpg and my exiftool version is 12.95_64

EvilZoid

Quote from: StarGeek on September 01, 2024, 10:55:06 AM
Quote from: EvilZoid on September 01, 2024, 05:08:21 AMI have a lot of pictures and videos, but their modified and created dates are incorrect. Is there a way to retrieve the original creation date and time from the media metadata (e.g., the "date taken" for images and the "media created" metadata for videos) and update the modified and created dates accordingly? I understand that some images might not have this information, so I'd like to move those files to a separate folder for manual correction.

These commands are for Windows CMD. You didn't mention your OS, so if it is Mac/Linux, you need to change the double quotes into single quotes and vice versa.

The first thing to do would be to separate the ones with no embedded timestamps. The reason you have to do this first is because videos will always have a CreateDate, but if the date isn't known, it will be set to all 0s.
exiftool -if "(not $CreateDate or $CreateDate='0000:00:00 00:00:00') and not $DateTimeOriginal" -Directory=/path/to/NoDates/ /path/to/files/


Thank you soo much these work for the images but not for videos? what do I have to change to fix that?

StarGeek

It works correctly here.

Make sure you're using CMD and not PowerShell. Also make sure you're not using the -api QuickTimeUTC option for this command.

What is the output of this command on one of the videos that fails?
exiftool -time:all -G1 -a -s file.mp4
* 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).

EvilZoid

Quote from: StarGeek on September 02, 2024, 02:55:07 PMIt works correctly here.

Make sure you're using CMD and not PowerShell. Also make sure you're not using the -api QuickTimeUTC option for this command.

What is the output of this command on one of the videos that fails?
exiftool -time:all -G1 -a -s file.mp4

actually nvm, sorry I was being stupid but what I have realize is that the command "exiftool -if "(not $CreateDate or $CreateDate='0000:00:00 00:00:00') and not $DateTimeOriginal" -Directory=/path/to/NoDates/ /path/to/files/" which moves file also moves videos with the dates.