ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Seb88 on February 08, 2024, 11:35:47 AM

Title: Exiftool ; Copy dates (or tags) from a backup in mirror to the originals files
Post by: Seb88 on February 08, 2024, 11:35:47 AM
Good morning everyone,

I'm completely new on Exiftool, cause I try to solve on problem.
A few weeks ago, I decided to sort out and tag every Family pictures I have, since 20 years. I decided to correct dates as well, to have a good timeline in a gallery for example. Some dates were missing, some not the good ones, some were good.

I have my Family pictures folder, and I use Lightroom to add every tags, which was very long but not hard to do.
Beside I changed dates with XnView.
I finished the job a few days ago. But here the problem :
I don't what happened, or what I did, but the date on almost every picture changed from 3 days to 14days, with a time change as well. Not the same offset of course.
So I was thinking "not a big deal, I will take the backup I have on my Extern Hard Disk, replace it, and save tags one again in LR". But no. If I do it, LR don't want to save tags in the "new file" (I guess cause the modified date is different".
I tried to cheat and to use and another software to bypass that (Capture One) and doesn't work neither.

And cause dates weren't change by LR, and can't use the "reset with the original date" button.
So changing the file doesn't work. But if I update the file with a good date, LR accept, and I can read the file and have the good date in LR..... but no tags anymore.

I also tried to use the IPTC create time in pictures to find the original time, with this command :

exiftool "-Exif:CreateDate<$Iptc:DateCreated $Iptc:TimeCreated" -if not $Iptc:DateCreated"

But not every picture has one (especially pictures between 2000 and 2010).

The only place were all the dates are good are one my backup. But I can't save the tags in it.

So now, my two last ideas are :

- Try to copy the CaptureDate of my backup files to every files used by LR (I update the date, and I don't change the file),
- Compare backupfiles (on my 2nd externe hard disk) to the "good" files (on my first extern hard disk), and if the name is exactly the same (with the same directory, as the two locations are just a mirror), I will copy tags in the backup file.

Two ways to obtain the same thing, but I don't see something else.


I tried to have a look on the Copy documentation, but I don't understand how I can compare file per file to know if I need to copy the tags (or date, depend of the technik) or not.

Cause I'm a rocky, I don't know where to start and how to proceed.

Does someone could help me ?
And tell me if my explanation isn't good (or if you have other ideas).

Have a beautiful day,


-Seb
Title: Re: Exiftool ; Copy dates (or tags) from a backup in mirror to the originals files
Post by: StarGeek on February 08, 2024, 12:03:22 PM
Quote from: Seb88 on February 08, 2024, 11:35:47 AMI don't what happened, or what I did, but the date on almost every picture changed from 3 days to 14days, with a time change as well. Not the same offset of course.

Which date?  What are you using to look at this "Date"?  There are about 90 different Date/Time tags that exiftool can write in an image by default and more if you count the ones that are marked as Avoid.

Run this command on some of the problem files
exiftool -time:all --system:all -G -a -s file.jpg

Then look at the output and see which tag matches the "Date" you are seeing in the other program. Also see which tag has the correct date.  You would then copy from one tag to the other with something like
exiftool "-BadTAG<GoodTag" /path/to/files/

I'm guessing that the tag you want to fix will be the FileModifyDate, as that is the most common answer.

I also tried to use the IPTC create time in pictures to find the original time, with this command :

Quoteexiftool "-Exif:CreateDate<$Iptc:DateCreated $Iptc:TimeCreated" -if not $Iptc:DateCreated"

But not every picture has one (especially pictures between 2000 and 2010).

This command as written will always fail.  You are checking to make sure that the DateCreated does not exist and files with it will be skipped. And if DateCreated doesn't exist, it can't be copied into the CreateDate, so the copy operation will fail.

The IPTC tags are an older standard and you should be using EXIF or XMP tags if possible.  Lightroom should be writing XMP tags by default.

Which reminds me of something that Lightroom does.  When you say
QuoteBut if I update the file with a good date, LR accept, and I can read the file and have the good date in LR..... but no tags anymore.

Lightroom is probably checking the IPTCDigest and since it no longer matches the hash of the existing IPTC data, it might be tossing out the original info because of this. Though that depends upon if any other program is writing or not.

Try running this command on one of the files before updating it, and before you start up LR
exiftool -IPTCDigest= file.jpg

This is one main reason I suggest avoiding IPTC IIM tags if possible. Note that IPTC IIM is not the same as IPTC Core/Ext, which writes to the XMP tags.

One final thing to check for is if there are XMP sidecar files.  If they exist, they will also have to be updated.
Title: Re: Exiftool ; Copy dates (or tags) from a backup in mirror to the originals files
Post by: Seb88 on February 08, 2024, 04:59:42 PM
First of all, thanks for your answer.

It wasn't clear actually, you're right. I want to save my Capture time, so the tag Date Taken.
I'm sure there is an offset for every picture, cause fortunatly, I always name my folder with "yyy-mm-dd". So there is a difference between the date on the folder and the Taken Date Tag.


QuoteRun this command on some of the problem files
exiftool -time:all --system:all -G -a -s file.jpg

Apparently, what's used by LR is composite DateTimeCreated

QuoteLightroom is probably checking the IPTCDigest and since it no longer matches the hash of the existing IPTC data, it might be tossing out the original info because of this. Though that depends upon if any other program is writing or not.
That's a good idea. I tried but first, it didn't work. And actually there is an another problem : LR don't allow to uptade juste one kind of tag (If it might working, I'd need to update just the tags, however when you update Metadata with LR, it's updating all, including tags and taken Date. In my case I need to update just one of them. So I guess it's not by this way I can find the solution.


QuoteThis is one main reason I suggest avoiding IPTC IIM tags if possible. Note that IPTC IIM is not the same as IPTC Core/Ext, which writes to the XMP tags.

I agree, it's just an thing I saw, that the IPTC stayed on some pictures, so I wanted to use it to have my date back. Not a good idea neither cause the dates are not always present.


I guess the best should be to copy the date from one file (the good one with the good taken date) to the other file, exactly with the same name but with the bad Taken date, located in the same directory, just instead of P: , the device is T:
For example :
Hard disk with Backup   "P:\Media\Family Pictures\2010-2019\2010-01-30 - Snow\Winter01"
Hard disk with bad pics "T:\Media\Family Pictures\2010-2019\2010-01-30 - Snow\Winter01"

And I need to do it in batch, cause it's for 17,000 files.

Is that possible to create a exiftool command for that ?
Title: Re: Exiftool ; Copy dates (or tags) from a backup in mirror to the originals files
Post by: StarGeek on February 09, 2024, 01:54:23 AM
Quote from: Seb88 on February 08, 2024, 04:59:42 PMI want to save my Capture time, so the tag Date Taken.

There's no such thing as a "Date Taken" or "Taken Date" tag.  These are usually properties that programs fill from a variety of tags, depending upon what is in the file.  For example, the "Date Taken" that you can find in Windows Properties->Details tab will be filled with values from five different tags. See this post (https://exiftool.org/forum/index.php?topic=6591.msg32875#msg32875) for more details on Windows Properties.

QuoteApparently, what's used by LR is composite DateTimeCreated

Composite tags (https://exiftool.org/TagNames/Composite.html) are not actually in the file, they are created by exiftool on the fly by combining other tags.  In this case, if Composite:DateTimeOriginal is correct, then you were on the right path before, as Composite:DateTimeOriginal is created by combining IPTC:DateCreated and IPTC:TimeCreated.

QuoteI guess the best should be to copy the date from one file (the good one with the good taken date) to the other file, exactly with the same name but with the bad Taken date, located in the same directory, just instead of P: , the device is T:
For example :
Hard disk with Backup  "P:\Media\Family Pictures\2010-2019\2010-01-30 - Snow\Winter01"
Hard disk with bad pics "T:\Media\Family Pictures\2010-2019\2010-01-30 - Snow\Winter01"

And I need to do it in batch, cause it's for 17,000 files.

Is that possible to create a exiftool command for that ?

Assuming that the tags that needed to be copied are the IPTC ones, then your command would be
exiftool -TagsFromFile "P:\%:1d%f.%e" -IPTC:DateCreated -IPTC:TimeCreated "T:\Media\Family Pictures\2010-2019\2010-01-30 - Snow\Winter01"

The %:1d takes the directory path of the target file that's on T and removes top most directory.  In this case T:\. This is prepended with the source diretory, "P:\" and then %f.%e is the base filename and extension.

This command creates backup files.  Add -Overwrite_Original (https://exiftool.org/exiftool_pod.html#overwrite_original) to suppress the creation of backup files.  Add -r (https://exiftool.org/exiftool_pod.html#r-.--recurse) to recurse into subdirectories.

If you find there are other tags you also want to copy, you can add them after TimeCreated.
Title: Re: Exiftool ; Copy dates (or tags) from a backup in mirror to the originals files
Post by: Seb88 on February 16, 2024, 01:19:54 PM
Hello Stargeek,

Sorry to not giving answer since a few days, I was unvailable.

QuoteThere's no such thing as a "Date Taken" or "Taken Date" tag.  These are usually properties that programs fill from a variety of tags, depending upon what is in the file.  For example, the "Date Taken" that you can find in Windows Properties->Details tab will be filled with values from five different tags. See this post for more details on Windows Properties.

I see. Actually if I try to copy tags and not update dates anymore, I will not use that.

QuoteAssuming that the tags that needed to be copied are the IPTC ones, then your command would be
exiftool -TagsFromFile "P:\%:1d%f.%e" -IPTC:DateCreated -IPTC:TimeCreated "T:\Media\Family Pictures\2010-2019\2010-01-30 - Snow\Winter01"

The %:1d takes the directory path of the target file that's on T and removes top most directory.  In this case T:\. This is prepended with the source diretory, "P:\" and then %f.%e is the base filename and extension.

This command creates backup files.  Add -Overwrite_Original to suppress the creation of backup files.  Add -r to recurse into subdirectories.

If you find there are other tags you also want to copy, you can add them after TimeCreated.

So I followed your directories, and here what I have (in attachment).

I created a test folder, to have a try first.
The command scan the folder, but apparently it can't read (and I guess upload the tags data).
I don't use the command with dates, as I don't want to copy dates anymore.

What do I do wrong ?

Screenshot.png
Title: Re: Exiftool ; Copy dates (or tags) from a backup in mirror to the originals files
Post by: Seb88 on February 16, 2024, 03:45:55 PM
Actually I understood some mistakes I made.

Here the command I used (to copy Tags), and apprently, it worked !
exiftool -TagsFromFile "T:\%:1d%f.%e" -EXIF:XPKeywords -IPTC:Keywords "E:\test" -Overwrite_Original -r

Thanks for your precious help !