File list to exiftool

Started by mrbrahman, December 24, 2017, 02:09:23 PM

Previous topic - Next topic

mrbrahman

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


Phil Harvey

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

mrbrahman

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.

mrbrahman

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 :-)

Hayo Baan

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)
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

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

rasto

Hi, can i use string here? (i need to fill it from array)

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

exiftool ARGS -@ $string

StarGeek

Not in that manner.  You could pipe it and have exiftool read it from stdin

echo $string | exiftool -@ - <more 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