Unable to find files where name ne exif OriginalDateTime

Started by plumberg, February 25, 2024, 10:16:36 PM

Previous topic - Next topic

plumberg

So, I have a few files where the exif data and filenames are not in sync.

I want to try and figure out which files are not matching the condition and list them. All are .jpg in a single folder running Windows. I would rather check this programmatically first before renaming files.

.\exiftool  -if "$Filename ne $DateTimeOriginal" -d "%Y%m%d_%H%M%S.jpg" 20170913_204703.jpg  -v -p "FileName Not Matching with exif data"
But, at each run, it says 1 files failed condition.

What am I doing wrong?
Thanks in advance
PS: -p option is for simply printing some output, correct? 

StarGeek

What command line are you using?  And are you sure that the file has a DateTimeOriginal tag?
"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

plumberg

Quote from: StarGeek on February 25, 2024, 10:58:26 PMWhat command line are you using?  And are you sure that the file has a DateTimeOriginal tag?

Windows Powershell.

Yes, the tag is present

.\exiftool.exe 20170913_204703.jpg -json -DateTimeOriginal
[{
  "SourceFile": "20170913_204703.jpg",
  "DateTimeOriginal": "2017:09:13 20:47:03"
}]

StarGeek

Quote from: plumberg on February 26, 2024, 09:21:01 AMWindows Powershell.

Always look at the highlighting when using PS.  In this case, the highlighting around $Filename and $DateTimeOriginal will be different, showing that they are considered PS variables and not part of the exiftool command.  See this post for an example.

You can try changing the quotes to single and see if that works, but it may not as shown by the command in the above link.  Powershell can fail on standard exiftool commands do to its quoting rules.

My advice is to use CMD instead of PS for exiftool commands.

"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

plumberg

Quote from: StarGeek on February 26, 2024, 10:55:15 AM
Quote from: plumberg on February 26, 2024, 09:21:01 AMWindows Powershell.

Always look at the highlighting when using PS.  In this case, the highlighting around $Filename and $DateTimeOriginal will be different, showing that they are considered PS variables and not part of the exiftool command.  See this post for an example.

You can try changing the quotes to single and see if that works, but it may not as shown by the command in the above link.  Powershell can fail on standard exiftool commands do to its quoting rules.

My advice is to use CMD instead of PS for exiftool commands.


o dear. Thank you so much for the clarification. Replacing it with single quotes did the trick.

I never realized this. I have some code already in powershell which I want to utilize and do some logic checks. If it gets too complicated (which I believe it will), I will end up switching to cmd as you suggest.


plumberg

On a side note, here is what worked:

.\exiftool  -if '$Filename ne $DateTimeOriginal' -d '%Y%m%d_%H%M%S.jpg' 20201221_211523.jpg -p 'Not same'

But, I am running into a small issue where this same command, as is, is failing in a .ps1 script as the condition is failing.... If you can share what I need to do, it would be great. Thanks in advance!

StarGeek

#6
I'm sorry but I can't help with Powershell.  It breaks too many commands that work perfectly fine in Windows CMD (edit: change to specify CMD), Mac, and Linux, and actively prevents you from using basic Linux commands, such as WGet and cURL when you have ports of those on your system.  That doesn't even take into account the fact that it corrupts binary data when doing things like extracting thumbnails from a file.

Regarding the percent signs, I don't know if a PS script has the same problem with them as a BAT file, but see FAQ #27, My ExifTool command doesn't work from a Windows .BAT file
"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

plumberg

Quote from: StarGeek on February 27, 2024, 11:28:49 AMI'm sorry but I can't help with Powershell.  It breaks too many commands that work perfectly fine in Windows, Mac, and Linux, and actively prevents you from using basic Linux commands, such as WGet and cURL when you have ports of those on your system.  That doesn't even take into account the fact that it corrupts binary data when doing things like extracting thumbnails from a file.

Regarding the percent signs, I don't know if a PS script has the same problem with them as a BAT file, but see FAQ #27, My ExifTool command doesn't work from a Windows .BAT file

I understand. Thank you for the note and all your help!