ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: mrbrahman on December 24, 2017, 02:09:23 PM

Title: File list to exiftool
Post by: mrbrahman on December 24, 2017, 02:09:23 PM
Hi,

How can I send the output of a command that lists the full path of the file to exiftool?

For eg, I would like exiftool to process different files thus:

exiftool -xmp:regionname-=nameX -xmp:regionname+=nameY dir1/file\ 1.jpg dir2/subdir2/file2.jpg dir3/file3.jpg

(Some files may contain spaces)

The list of files come from another command (it's a search script that searches for terms in metadata files of my library (184GB) that I generate per folder of using exiftool) like below

$ perl search.pl face=nameX
dir1/file 1.jpg
dir2/subdir2/file2.jpg
dir3/file3.jpg

Title: Re: File list to exiftool
Post by: Phil Harvey on December 24, 2017, 02:20:26 PM
You can do this using shell backticks on Mac/Linux:

exiftool ARGS `perl search.pl face=nameX`

Except that names with spaces may be a problem.  Otherwise you could do this and spaces won't be a problem:

1. perl search.pl face=nameX > out.txt
2. exiftool ARGS -@ out.txt

But you may be able to save a step by using the exiftool -if option to find the files you want to process.  For example:

exiftool ARGS -if '$TAG =~ /nameX/' -r DIR

- Phil
Title: Re: File list to exiftool
Post by: mrbrahman on December 24, 2017, 03:06:54 PM
Thanks Phil! The 2 step process using -@ worked!

Quote from: Phil Harvey on December 24, 2017, 02:20:26 PM
But you may be able to save a step by using the exiftool -if option to find the files you want to process.  For example:

exiftool ARGS -if '$TAG =~ /nameX/' -r DIR

I would really like to use this option, as it is clean and simple. But when I tried it before, I had to kill it after 8 mins of waiting. It looks like the single threaded process does need time to go through 184 GB of photos and videos. And that's why I have a separate script that generates metadata by folder, which I use for my search purposes.
Title: Re: File list to exiftool
Post by: mrbrahman on December 24, 2017, 09:26:13 PM
Just as a note to self, the below one-liner (using xargs) seems to work nicely as well.

perl search.pl face=nameX | xargs -d '\n' exiftool -xmp:regionname-=nameX -xmp:regionname+=nameY

But of course, this is only for systems that support xargs :-)
Title: Re: File list to exiftool
Post by: Hayo Baan on December 26, 2017, 03:39:06 AM
Nice! The -d '\n' is a very useful trick to use when the input of xargs consists of lines of files that may have spaces 8)
Title: Re: File list to exiftool
Post by: Phil Harvey on December 26, 2017, 08:35:27 AM
Quote from: mrbrahman on December 24, 2017, 09:26:13 PM
Just as a note to self, the below one-liner (using xargs) seems to work nicely as well.

perl search.pl face=nameX | xargs -d '\n' exiftool -xmp:regionname-=nameX -xmp:regionname+=nameY

This one-liner should work as well -- no need for xargs:

perl search.pl face=nameX | exiftool -@ - -xmp:regionname-=nameX -xmp:regionname+=nameY

- Phil
Title: Re: File list to exiftool
Post by: rasto on February 05, 2022, 04:12:33 PM
Hi, can i use string here? (i need to fill it from array)

$string="IMG1.nef\nIMG2.nef\nIMG3.nef"

exiftool ARGS -@ $string
Title: Re: File list to exiftool
Post by: StarGeek on February 05, 2022, 05:50:57 PM
Not in that manner.  You could pipe it and have exiftool read it from stdin

echo $string | exiftool -@ - <more commands>