Output messages shown as error in PowerShell

Started by Tardisdude, March 12, 2025, 08:06:58 AM

Previous topic - Next topic

Tardisdude

Hi!

I'm using the portable version of ExifTool 13.25 (without the -k in the executable filename) to extract tags from files in a directory to a CSV from a PowerShell script.

When using the -csv option, output messages such as "X directories scanned", "X image files read" and the output from the -progress option are shown as errors. The same thing happens when using the -j (JSON) option.

I've tried redirecting STDERR to STDOUT with 2>&1 with no success. This issue is not present when ExifTool is run from the command line.

Would anyone have any idea on how to output these message as STDOUT?

Screenshot 2025-03-12 080046.png

FrankB

In ExifToolGui you can create a PS script. here is a sample:

exiftool  -echo4 `{readyxx`} -CHARSET FILENAME=UTF8 -v0 -overwrite_original -sep * -m -c %.6f° -API WindowsWideFile=1 -API WindowsLongPath=1 -exif:all _IGP0002.dng -executexx 2>&1 | %{"$_"}

This is the interesting part.
2>&1 | %{"$_"}
Hope it helps

Phil Harvey

You could add -q to suppress these messages if you wanted.

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

Tardisdude


elhiero

I had the same problem ...
I don't remember how it worked, an AI helped me get the Exiftool responses in a file, and keep the report messages on the console withot causing an error
        $TempFile = "$BaseFolder\TempFile.txt"
        if (Test-Path $TempFile) { Remove-Item $TempFile }
        Write-Host -NoNewline " ExifTool ... " ;

        & $ExifToolName -m -F -r -ext jpg -p $ExifToolArgs "$FolderPath" 1>>$TempFile 2>>null
        Write-Host -NoNewline "$error "
        Add-Content -Path $BaseFolder\$LogFile -Value "$error"
        $Error.Clear()

        if (Test-Path $TempFile) {
            $ExifData = Get-Content $TempFile
            $FormattedExifData = $ExifData -join " "
            $Line += " $FormattedExifData"
            Remove-Item $TempFile
        }