READING SourceFiles from CSV or text file

Started by ejm554, October 05, 2018, 01:21:14 PM

Previous topic - Next topic

ejm554

Can ExifTool read a set of SourceFiles listed in a CSV file and return a given tag (if it exists)?

If not, is there another way to have ExifTool read a selected set of files, short of adding them to the actual command line?

Example scenario: I want to read a set of 1,000 files — already properly listed in a text file — which all reside in a containing directory of 50,000 files and subdirectories. Presumably, its not reasonable to paste 1,000 file paths in the command line at the end of my ExifTool command.

I've run into a number of occasions where I want to do something like this in ExifTool, but I cannot figure out how to do it. Currently, I've been working around the problem by reading a ton of unwanted files (like the complete containing directory in my example scenario), outputting results to a CSV file, then using a SQL tool to compare that output to another CSV listing the files I want.

Knowing how powerful ExifTool is, I'm guessing there's already a way to do this sort of thing. Is there?

Regards,
EJ

Phil Harvey

The -@ option allows you to read command-line arguments (eg. file names) from another file.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

ejm554

Great! But I need guidance to make sure I'm understanding.

If my ARGFILE looked like this:
# --------------------------------------------------
# File: Copyright.ARGS
# Purpose: READ the Copyright tag of five files.
# --------------------------------------------------
-copyright
/Users/ejm/Images/Foo/1999/Screenshot1.jpg /Users/ejm/Images/Foo/2001/File-add-icon.png
/Users/ejm/Images/Bar/2018/20180902_231139.jpg /Users/ejm/Screenshots/2018-08/2018-08-29_18-14-32.png /Users/ejm/Screenshots/2018-09/2018-09-24_19-32-27.png
# ----- End of file -----


And then I ran this command:
$ exiftool -@ Copyright.ARGS

Would I see output?

If so, would the output be identical to the output of this command?:
$ exiftool -copyright /Users/ejm/Images/Foo/1999/Screenshot1.jpg /Users/ejm/Images/Foo/2001/File-add-icon.png
/Users/ejm/Images/Bar/2018/20180902_231139.jpg /Users/ejm/Screenshots/2018-08/2018-08-29_18-14-32.png /Users/ejm/Screenshots/2018-09/2018-09-24_19-32-27.png



StarGeek

It has to be one file per line.  Otherwise in your example, exiftool will look for a single file with the name of
"/Users/ejm/Images/Foo/1999/Screenshot1.jpg /Users/ejm/Images/Foo/2001/File-add-icon.png"
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

ejm554

Hmm. I believe you, but I may be misunderstanding something else then.

1. Would the following example work if run on the command line? (I presume that it would.)
$ exiftool -copyright /Users/ejm/Images/Foo/1999/Screenshot1.jpg /Users/ejm/Images/Foo/2001/File-add-icon.png
/Users/ejm/Images/Bar/2018/20180902_231139.jpg /Users/ejm/Screenshots/2018-08/2018-08-29_18-14-32.png /Users/ejm/Screenshots/2018-09/2018-09-24_19-32-27.png


2. If so, then why do I (or even how can I) use one file per line in the ARGFILE?
The ExifTool documentation for the -@ option says: "The file contains one argument per line..." and "Arguments in ARGFILE behave exactly the same as if they were entered at the location of the -@ option on the command line..."

I wouldn't be able to enter one file per line via the command line, unless preceded with exiftool -copyright. (Right?)

EJ

Phil Harvey

On the command line, arguments are separated by spaces or tabs.

In an argfile, they are separated by newlines.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

My apologies.  I was in a hurry (reading while playing a game) and didn't clarify that I was talking about an arg file.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

ejm554

Okay. I assumed that a list of multiple files was considered one argument. But it sounds like each file is its own argument, i.e., 5 files on the command line is processed as 5 different arguments.

Is that correct?

EJ

StarGeek

Anything that needs to be separated by a space is a separate argument.  For example, the -d option requires a date format string.  The -d is one argument, the date format string is a separate argument.  In an arg file, you would have to use
-d
%Y%m%d_%H%M%S
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

ejm554