Question

I'm trying to search hundreds of files for the keyword 'Description' and then output the name of a file that contains the keyword.

Executing a simple exiftool * | grep Description (in UNIX) gives me the line in the file but not the name of the file that contains the line. By default, the file name and description are output on two separate lines like the two below.

File Name                       : [Name of file listed here]
Description                     : [a long string here]

I think there's a way to do this in ExifTool without even needing to pipe the output to grep but I haven't been able to figure it out.

Was it helpful?

Solution

There are lots of ways to do this. Here is one:

exiftool -if '$description' -filename -r .

or if you want both the file name and description on the same line:

exiftool -p '$filename $description' -r -q -q .

and if you also want the directory:

exiftool -p '$directory/$filename $description' -r -q -q .

  • Phil

OTHER TIPS

Assuming the two were on lines right next to each other, grep also accepts the -B 1 switch, which stands for include the number of lines before the match.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top