Main Menu

IF and Only IF

Started by wesley, November 05, 2022, 04:44:42 PM

Previous topic - Next topic

wesley

I have two commands, work great.

exiftool -r -overwrite_original -Comment"<BaseName" /Volumes/Media
exiftool -r -overwrite_original -Title"<BaseName" /Volumes/Media

But I would like them to work "IF and Only IF" the title and or comment is DIFFERENT from BaseName. I'd like to run this semi regularly, but don't want to go through all the trouble if its already been done once.

is that possible?

is it also possible to merge the two commands into one?

Thanks!

Phil Harvey

This should do it:

exiftool -r -overwrite_original -Comment"<BaseName" -Title"<BaseName" -if "not $comment or not $title or $comment ne $basename or $title ne $basename" /Volumes/Media

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

wesley

Quote from: Phil Harvey on November 05, 2022, 09:13:11 PMexiftool -r -overwrite_original -Comment"<BaseName" -Title"<BaseName" -if "not $comment or not $title or $comment ne $basename or $title ne $basename" /Volumes/Media

That doesn't appear to work. I am testing it on a single directory.. relevant metadata is:

ExifTool Version Number         : 12.42
File Name                       : Violin Rehersal (2022).mp4
Directory                       : .
Comment                         : Violin Rehersal (2022).mp4
XMP Toolkit                     : Image::ExifTool 12.42
Title                           : Violin Rehersal (2022).mp4
 
when I run
Quoteexiftool -r -overwrite_original -Comment"<BaseName" -Title"<BaseName" -if "not $comment or not $title or $comment ne $basename or $title ne $basename" ./ 

I get

1 directories scanned
1 files failed condition
0 image files read

The file exist as:
Violin Rehersal (2022).mp4

Phil Harvey

What O/S are you using?  Did you read my signature?

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

wesley

Quote from: Phil Harvey on November 06, 2022, 09:05:16 PMWhat O/S are you using?  Did you read my signature?

- Phil

Of course, that fixed it!

thanks

wesley

Is there a log? or a way to see which failed the condition? more verbose output?


1010 directories scanned
17 files failed condition
0 image files read

StarGeek

"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

Phil Harvey

Hi Wesley,

To get a log of all files that failed the condition, you can use the -efile4 option, like this:

exiftool -efile4 log.txt ...

Read the -efile option documentation for more details.

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