ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: avw1957 on July 24, 2023, 10:29:42 AM

Title: Exiftool return codes
Post by: avw1957 on July 24, 2023, 10:29:42 AM
Hi!

since I´d like to use exiftool from a PowerShell script in order to get EXIF info for photo and video files, I need to know what return codes can be expected.

To keep things "simple", I´d like to "walk" recursively (in PowerShell) through a directory which contains a lot of different files and filetypes as well.

Then I have 2 possibilities:

What is the beszt way?

Thx very much!
Title: Re: Exiftool return codes
Post by: StarGeek on July 24, 2023, 10:56:26 AM
From the docs on Exit Status (https://exiftool.org/exiftool_pod.html#EXIT-STATUS)
QuoteThe exiftool application exits with a status of 0 on success, or 1 if an error occurred, or 2 if all files failed the -if condition (for any of the commands if -execute was used).

Also, if you are working with a large number of files, then calling exiftool once per file will significantly increase processing time (see Common Mistake #3 (https://exiftool.org/mistakes.html#M3)).  Exiftool's startup time is it's biggest performance hit.  If at all possible, it's best to give exiftool all the files/directories to process and then parse the output data.

Or you could look into the -stay_open option (https://exiftool.org/exiftool_pod.html#stay_open-FLAG), which keeps exiftool running in the background, allowing for interactive processing.

While it might be less of a problem for you if you're more familiar with Powershell, PS doesn't like the formatting of some standard exiftool commands. This post (https://exiftool.org/forum/index.php?topic=14962.msg80581#msg80581) shows a common type of exiftool command and shows quoting that works with Mac/Linux and with CMD, but neither work with PS.  I've long since given up trying to figure out PS's idiosyncrasies compared to standard command lines.
Title: Re: Exiftool return codes
Post by: avw1957 on July 24, 2023, 11:09:08 AM
I really didn´t ponder "exit codes" instead of "return codes". My bad.
Will definitely use your suggestions  ;D
Thx a lot!