Help with changing metadata dates

Started by raptorpete, December 29, 2021, 02:40:25 PM

Previous topic - Next topic

raptorpete

I have an issue with my photos where the date is part of the title, such as "IMG_20130407.jpg" but the metadata for these photos are nonexistent. I am wanting to update the metadata so that they show up properly in the Synology photos timeline.  Would any software developer know of any easy script that could help fix this with ExifTool?

Phil Harvey

This is a very common question.  Since your file names don't contain a time, you'll have to add one (I'll assume you want to set the time to 00:00:00).  The basic command looks like this:

exiftool "-alldates<$filename 00:00:00" -ext jpg DIR

The command writes AllDates, which is a shortcut for CreateDate, ModifyDate and DateTimeOriginal, so all 3 of these tags will be set from the file name.  I've added the -ext jpg option to only process JPG files in the specified directory.

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

StarGeek

You do want to make sure that the files actually are missing the data as this command will overwrite existing time stamps.  You can add -wm cg to the command to make sure nothing is overwritten.
"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

raptorpete

Quote from: Phil Harvey on December 29, 2021, 03:04:31 PM
This is a very common question.  Since your file names don't contain a time, you'll have to add one (I'll assume you want to set the time to 00:00:00).  The basic command looks like this:

exiftool "-alldates<$filename 00:00:00" -ext jpg DIR

The command writes AllDates, which is a shortcut for CreateDate, ModifyDate and DateTimeOriginal, so all 3 of these tags will be set from the file name.  I've added the -ext jpg option to only process JPG files in the specified directory.

- Phil

My file also is prefixed with "IMG_".  Is that an issue for the AllDates command?  Is there a way to tell Alldates to ignore that?  Also, I tried your code above and got this error:

Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z])

Phil Harvey

> exiftool IMG_20130407.jpg -alldates
> exiftool IMG_20130407.jpg '-alldates<$filename 00:00:00'
    1 image files updated
> exiftool IMG_20130407.jpg -alldates
Date/Time Original              : 2013:04:07 00:00:00
Create Date                     : 2013:04:07 00:00:00
Modify Date                     : 2013:04:07 00:00:00
> exiftool -ver
12.38


Here I used single quotes instead of double quotes since I'm on a Mac.

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

StarGeek

Quote from: raptorpete on December 29, 2021, 05:57:23 PM
My file also is prefixed with "IMG_".  Is that an issue for the AllDates command?

Any non-number character won't make any difference but if there are other numbers in the file name that are not part of the date/time such as a copy number, that would interfere.

If you're using Linux/Mac/PowerShell, you need to use single quotes.  if you're using Windows CMD, you need to use double quotes.  Also make sure you are using straight quotes, not fancy curly quotes such as what a word processor will substitute.
"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

raptorpete

Okay so now I have gotten the tool to process everything in the directory but it was very strange behavior.  First of all, I could only make it work if I omitted the timestamp.  Second of all, I now how 2 copies of each file... one that has the original filename and one that says filename.jpg_original.  Furthermore, the dates in the metadata were not even changed.  They still say Modified to be Dec 2021 instead of the actual dates which are from 2013/2014.



Any suggestions?


StarGeek

Quote from: raptorpete on December 30, 2021, 09:24:49 AM
First of all, I could only make it work if I omitted the timestamp.

Looking at your image, you didn't use the command posted above.  You made Common Mistake #5c, where you used an equal sign = while the examples above show a less than sign <

Additionally, though it's hard to tell, it doesn't look like you're using CMD due to the fact that you have exiftool preceded by an ampersand and enclosed in single quotes, which is a PowerShell thing.  But then you put the exiftool options in double quotes even though I posted above that you need to change them when using PS.

QuoteSecond of all, I now how 2 copies of each file... one that has the original filename and one that says filename.jpg_original.

By default, exiftool creates backup files, as per the second paragraph under Description in the docs.  You can suppress the creation of backup files by adding -overwrite_original option, though I suggest that you don't until you are absolutely sure that you are using the correct command.  Test a command then use the restore command I list below.  There is only one level of backup so you want to restore before you test again.

Also, your image shows that the filename includes a time, so the 00:00:00 isn't needed for those files.

QuoteFurthermore, the dates in the metadata were not even changed.  They still say Modified to be Dec 2021 instead of the actual dates which are from 2013/2014.

That shows the file system time stamps, not the embedded EXIF data.  You would change those by copying to FileModifyDate instead of AllDates.  Additionally, you said it's on a Synology.  There is usually a background program on the Synology  that will prevent alteration of FileModifyDate.

Also, it's very likely that the files already have embedded EXIF timestamps and you don't want to be running the above command anyway, since you weren't looking at the wrong metadata.  Google does not remove metadata from the files you upload.  The only time you want to change photos that you get from Google Takeout is when you added or changed information for those files on the Google website.

Here's what I suggest. First, undo everything you just did with this command to restore the originals.
exiftool -restore_original /path/to/files

Then pick one of the files and double check to make sure it is missing the EXIF time stamps with this command
exiftool -time:all --system:all -G -a -s /path/to/files/
If you see something like this, which has the three EXIF time stamps, possibly others
C:\>exiftool -time:all --system:all -G -a -s y:\!temp\Test4.jpg
[EXIF]          ModifyDate                      : 2021:12:30 08:12:29
[EXIF]          DateTimeOriginal                : 2021:12:30 08:12:29
[EXIF]          CreateDate                      : 2021:12:30 08:12:29

Then you do not need to edit the data in those files, they already have the original time stamps.

Finally, to fix the FileModifyDate, you would run this command
exiftool '-FileModifyDate<Filename' /Path/To/Files/
Take note of the single quotes when on PowerShell and the use of the less than sign <.

But as I said, the Synology may prevent you from actually changing those dates.  This Google search will show previous questions about that problem on these forums and the program you need to disable is in one of those links.
"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

raptorpete