ExifTool in Powershell script gives error with many files

Started by KalTrek, December 19, 2024, 09:12:02 AM

Previous topic - Next topic

KalTrek

Hi,
first of all thank you for this incredible tool.

I wrote a Powershell script to organize my pictures.
It just moves files from a folder to subfolder with name yyyy-mm-dd.
The script also moves "companion" files linked to the main image, i.e. xmp or acr, even when they have a different date.
I ran the script in a trial folder but now that I'm trying to use it in a "real" folder with over 3000 pictures, I get this error:

Error getting EXIF data with ExifTool: Program 'exiftool.exe' failed to run: StandardOutputEncoding is only supported when standard output is redirected.At D:\Pictures\!NEW PICS\2016-11 Giappone\move_files 1.25.ps1:207 char:25
+             $exifJson = & $global:ExifToolPath @args

Any help would be really appreciated.
Thank you.


Phil Harvey

PowerShell has lots of problems, especially with corrupting piped output.  I suggest rewriting your script to use some other shell or language.

Alternatively, I suggest posting this question on a PowerShell board.  Experienced people here will probably just tell you not to use PowerShell.

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

KalTrek

Hi Phil,
thank you for the quick reply.

The problem is here:

 # Call ExifTool once for all files
            $exifJson = & $global:ExifToolPath @args

I thought that maybe someone could tell me an easy fix that eludes me.


StarGeek

That would take someone with understanding of PowerShell scripts.

The corruption that Phil refers to has to do with the fact that PS converts everything to UTF-16. You might try making sure that UTF-8 is being used.

But this is a PowerShell problem, not an exiftool one.

(Re-reading that article, I saw that it's even worse than simply converting everything to UTF-16. It's adding a carriage return 0x0d in front of every line feed 0x0a)
"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