سؤال

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.

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top