Replacing Shell "Find" and Exiftool with an Exiftool-only search

Started by alexlyman, November 07, 2016, 12:48:48 PM

Previous topic - Next topic

alexlyman

I'm no longer able to reliably write temp files to my user's local drives, which has led me to rethink my approach to looking up metadata tag values. I had been using a series of shell "find" commands to get a list of AI files that resided in directories with a standard names of "Graphics" and "Templates". I'd save these lists as arg files for Exiftool to use for the lookup. To get the desired metadata from the files, I have to perform 1 shell command to get my list of directories, 2 shell find commands to get my list of files, then two exiftool calls to get the list of metadata for those files.

To combine the Find and Exiftool commands, my temptation would be to do something like:
exiftool [tags to lookup] startingDirectory/*/*/graphics/*.ai where the app that's doing the lookup would add as many "/*" as needed to match the maxdepth value I'd use in the find that gives me my list of directories in which to search for graphics: find startingDirectory -maxdepth 2 -name 'graphics'

But that only simplifies to two lookups and adds a whole lot of wildcards that might misbehave.

Can exiftool be used to combine two searches, something like:
exiftool [tags to lookup] ('startingDirectory/*/*/graphics/*.ai' AND 'startingDirectory/*/*/templates.*_template*.ai)

Thanks,
Alex L.


Phil Harvey

You may put as many directory and/or file names on the exiftool command line as you want.

Alternatively, you could pipe the results of your find command directly to exiftool:

find <files to find> | exiftool -@ - <exiftool arguments>

or

exiftool `find <files to find>` <exiftool arguments>

in the second example, adding more find commands would be done like this:

exiftool `find <files to find>` `find <more files to find>` <exiftool arguments>

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

alexlyman

Phil, you are wonderful!

I wasn't able to make the second solution work, but the first solution worked fine. Once I combine the my find requests into a single command this will be perfect.

Thanks
-AL

alexlyman

Example of what DIDN'T work:

exiftool 'find ~/desktop -name "*.ai" -maxdepth 1' -t -filename -modifydate

(on a mac, current exiftool version, when run separately the find command works just fine)

Phil Harvey

Ah.  But you used single quotes instead of backticks.  I was taking advantage of the shell backtick feature.  Use backticks instead of single quotes and it should work for you.

- Phil

Edit:  But note that the second technique may run into command-line-length limitations if you have lots of files and very long paths.  (I think the limit is 262144 characters on OS X.)
...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 ($).

alexlyman

Again, brilliance from Phil. Missed that little bit of typographic significance.

using the backtick worked, and posed yet another opportunity for me to learn... spaces in the returned filenames will need to be escaped, but I think I can figure that out.

-ALex