extract metadata with EXIFTOOL called from MFC dialog (Windows)

Started by DocDJ, February 01, 2023, 09:06:35 AM

Previous topic - Next topic

Phil Harvey

Use -T instead of -s3 to get the output all on one line (tab separated).

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

DocDJ

Backslashes in the paths (image and output file paths) work but must be doubled.
Forward slashes do not have to be doubled because Windows does not care about them in parameter strings. Of course, the called program must be able to handle them, which EXIFTOOL does very nicely.

DocDJ

So I am happily getting my metadata into an output file, using the -T -s3 and -W+ options. However, the tabs written between values get replaced by the file I/O system as 3 spaces. (This also happens for tabs as part of a header written by other parts of my program.) Is there a way to get exiftool to use something other than a tab? I tried switching -T to -csv (and got no output at all), so I suspect that -csvDELIM won't help.

Phil Harvey

As mentioned, -csv can't be combined with -W.  Other than that, you should get an output.

You should really read the -csv option documentation.  It contains some hints that may be useful to solve your problems.

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

DocDJ

Per your previous comments, when I switched to -CSV, I had removed the -W option.
After numerous unsuccessful attempts to specify a filename for the CSV output, I discovered that exiftool would write the output to STDOUT. (So I wrote a function to redirect STDOUT to a file.) When I renamed that file as myout.csv (after running exiftool), it opened properly with Excel. Is there any way of specifying the actual path to that file? (I could not figure out a way to specify a file using the % formatting options, because every attempt caused exiftool to treat that file as another image input file.
The -o option caused the same effect.

StarGeek

Please reread this entire thread and read the links.  You're asking questions which have already been answered.

For example, in the third post I answer
Quote from: StarGeek on February 01, 2023, 11:13:27 AMThe -csv option will list the data in the CSV format as part of STDOUT.  So you will either need to capture STDOUT or redirect it into a file.
"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

DocDJ

Sorry, I did read them, but I had disregarded the stdout note, assuming that an existing option might be a way to do it without using stdout. (I assumed that the note was just an FYI that a developer could use to see the csv data). Also, I was concerned that other data (such as messages from exiftool) might also be there and mess up my post-processing. It wasn't clear (to me), that stdout was the ONLY way to get the output other than -W, which didn't let me use commas (the tabs were being replaced by the system, leaving no parse-able text to split the data out later.)
-o sounded like a good prospect, but I couldn't figure out a way to do that. Also, all the capabilities of CSVFILE seem to be relegated to reading from the csv file, not building one.

One other major problem with STDOUT is that I plan to process many directories in one run of exiftool, each having their own CSV file. That would mean closing, renaming the STDOUT file and creating a new one for each of those directories. Not difficult, but it slows down the operation. I have lots of directories to process and do it frequently as the files in each directory get updated/replaced.

DocDJ

I was able to combine the -p and -W+ options to get the effect of -CSV without having to do redirection of stdout (which proved to be problematic). I couldn't use -csv, because the tabs in the csv files get changed (by Windows) into spaces by the file system. Commas provided by the -p format rules make for easy post-processing.

Thanks for a great program!