Hi, I am brand new to ExifTool, so trying to figure out best way to tackle my issue.
I searched all the forum posts and found a few ways to do what I want, but hoping someone can fill in the gaps:
I have subfolders of photos (let's say 50+ subfolders) and inside those folders an average of about 50 photos.
Around 5-10 photos in random folders do not have "Date Taken" for various reasons.
But - they do have accurate Modified Date.
So I am thinking to copy Modified Date to Date Taken ONLY if Date Taken is empty, and to preserve modified date.
I have this so far but I am missing the "if empty" portion. Also will this do all subfolders under that root folder?
Thank you so much for any help!
exiftool "-datetimeoriginal<filemodifydate" -P DIR
Add the -wm (writemode) option (https://exiftool.org/exiftool_pod.html#wm-MODE--writeMode) and the -r (recurse) option (https://exiftool.org/exiftool_pod.html#r-.--recurse).
Recurse is simple, just add the -r and it will go into subdirectories.
Writemode needs an additional argument. I'd say -wm cg is what you want to use. It will not write to existing tags, just create new tags.
As with all things exiftool, another option would be to use the -if option (https://exiftool.org/exiftool_pod.html#if-EXPR). In this case, -if "not $DateTimeOriginal" would write only if DateTimeOriginal didn't exist.
Thank you for the help!
OK so would this work below? I will test tonight, just double checking syntax.
The -if statement goes first? then the action? then write mode and -r for recurse?
Have not looked up what the -P means yet but not sure I need it.
Thanks again!
-if "not $DateTimeOriginal" "-datetimeoriginal<filemodifydate" -wm cg -r -P DIR
-if must be followed by the condition and -wm must be followed by the appropriate Mode flags, but otherwise, for the most part, the order doesn't matter (there is one other case where order would matter which I can discuss if you're interested). If the -if condition fails, then the entire command is not processed. You want to keep the -P (Preserve) option (https://exiftool.org/exiftool_pod.html#P--preserve) as it preserves the FileModifyDate, which you mentioned you wanted.
Test it out first, of course, to make sure it's doing what you want.
StarGeek thank you for the help, I updated a TON of photos over past few days.
First few runs were tricky but then I got the hang of it.
LOVE this Tool, big thanks for the developer and all those helping the newbs on the Forum!
Hi all,
I am very new to ExifTool and find it challenging to use command line to get done what I need to do.
I am trying to 'clean up' my large photograph collection in the same way as mentioned in this thread. I have some photos missing the 'Date Taken' field. I wish to 'Copy Modified Date to Date Taken Only if Date Taken is Empty'.
I realise that tron who asked the question was able to correctly interpret what StarGeek has said to create the correct command line to achieve the objective. I am unable to do so.
Can you please provide me with the command line to do so, based on the above?
Thank you!
The command may be something like this:
exiftool "-datetimeoriginal<filemodifydate" -P -if "not $datetimeoriginal" -r DIR
This command will preserve "_original" files for each of the files that are changed. Once you are sure the command did the right thing, you can remove the _originals with this command:
exiftool -delete_original -r DIR
Or if you already have backups and want to prevent the _original files from being preserved, add -overwrite_original to the first command.
- Phil
Quote from: Phil Harvey on November 23, 2022, 09:14:58 AMThe command may be something like this:
exiftool "-datetimeoriginal<filemodifydate" -P -if "not $datetimeoriginal" -r DIR
This command will preserve "_original" files for each of the files that are changed. Once you are sure the command did the right thing, you can remove the _originals with this command:
exiftool -delete_original -r DIR
Or if you already have backups and want to prevent the _original files from being preserved, add -overwrite_original to the first command.
- Phil
Thank you for the help, Phil, but I could not get this to work on my test folder of 28 JPEG files with missing date taken. From my limited understanding, is there supposed to be a -wm in there somewhere?
The -wm w was an alternate method. You don't need this with the -if option I used.
You need to be more specific than just saying it didn't work. What was the ExifTool output?
- Phil
Hi Phil,
Here is the output.
(https://i.imgur.com/EJOgkpy.png)
And here are the files.
(https://i.imgur.com/06czBGs.png)
Thank you
So all of the images already had a DateTimeOriginal. According to StarGeek's post (https://exiftool.org/forum/index.php?topic=6591.msg32875#msg32875) I thought this would fill the Windows "Date Taken" property.
Some investigation is required. What does this command give on a file in question?:
exiftool -time:all -a -G1 -s FILE
- Phil
Hi Phil,
Thank you for your help. I get this.
(https://i.imgur.com/cFIFPWF.png)
Ah. That explains it. The tags exist but are invalid dates.
I also think we should probably fix the other date/times too. Try this somewhat longer command:
exiftool "-alldates<filemodifydate" -P -if "not $datetimeoriginal or $dateTimeOriginal !~ /^\d/" -r DIR
This will set the 3 date/time tags from the filesystem modification date if DateTimeOriginal doesn't exist or doesn't start with a digit.
- Phil
Thank you! That works! Although it only seems to work on JPG files and not PNG or other types of files.
Is there any way to make it happen on other types of files too?
Looking at the post I referenced by StarGeek (https://exiftool.org/forum/index.php?topic=6591.msg32875#msg32875), it looks like you need to write CreationTime in PNG files. Other types depends on what Windows will read from these files. Check StarGeek's post, but for other formats you may have to do some testing.
- Phil
Hi Phil,
Thank you so much for your help!
-Loupraid