File not found when both nonascii characters and spaces in filename in stay_open

Started by jcubed, September 19, 2020, 02:14:26 PM

Previous topic - Next topic

jcubed

Microsoft Windows [Version 10.0.18363.1082]
exiftool 12.06
I'm running both in cmd and Windows Terminal to the same result.

Works fine if there are no non-ascii characters, but there are spaces:
C:\WINDOWS\System32>exiftool -stay_open true -@ -
-j
D:\a e\a.jpg
-execute
[{
  "SourceFile": "D:/a e/a.jpg",
  "ExifToolVersion": 12.06,
  "FileName": "a.jpg",
  "Directory": "D:/a e",
  "FileSize": "2.5 MB",
...
}]
{ready}


It works fine if there are are non-ascii characters WITHOUT spaces:

C:\WINDOWS\System32>exiftool -stay_open true -@ -
-j
D:\ą\a.jpg
-execute
[{
  "SourceFile": "D:/?/a.jpg",
  "ExifToolVersion": 12.06,
  "FileName": "a.jpg",
  "Directory": "D:/?",
  "Warning": "FileName encoding not specified",
...
}]
{ready}


But it DOESN'T work when there are both spaces and non ascii characters:


C:\WINDOWS\System32>exiftool -stay_open true -@ -
-j
D:\a ę\a.jpg
-execute
Error: File not found - D:/a ę/a.jpg
{ready}
^C


Even if I try to add the -charset filename=utf8 it doesn't work, although it sometimes works if there is only one character(??????).

C:\WINDOWS\System32>exiftool -stay_open true -@ -
-j
-charset
filename=latin2
D:\ą e\a.jpg
-execute
[{
  "SourceFile": "D:/─ä e/a.jpg",
  "ExifToolVersion": 12.06,
  "FileName": "a.jpg",
  "Directory": "D:/─ä e",
  "FileSize": "2.5 MB",
...
}]
{ready}
^C
C:\WINDOWS\System32>exiftool -stay_open true -@ -
-j
-charset
filename=latin2
D:\ą ę\a.jpg
-execute
Error: File not found - D:/ą ę/a.jpg
{ready}
-charset
filename=utf8
D:\ą ę\a.jpg
-execute
Invalid filename encoding for D:/ą ę/a.jpg
Error opening directory D:/ą ę/a.jpg
{ready}
-charset
filename=latin
D:\ą ę\a.jpg
-execute
Error: File not found - D:/ą ę/a.jpg
{ready}
^C


Here is output of exiftool -echo:

C:\WINDOWS\System32>exiftool -echo "ą ę"
╣ ŕ

C:\WINDOWS\System32>exiftool -charset utf8 -echo "ą ę"
╣ ŕ


Works fine in regular fashion in command-line mode:

C:\WINDOWS\System32>exiftool "D:\ą ę\a.jpg"
ExifTool Version Number         : 12.06
File Name                       : a.jpg
Directory                       : D:/╣ ŕ
Warning                         : FileName encoding not specified
File Size                       : 2.5 MB
File Permissions                : rw-rw-rw-
...
File Type                       : JPEG
File Type Extension             : jpg
MIME Type                       : image/jpeg
Exif Byte Order                 : Little-endian (Intel, II)

Phil Harvey

The only difference between specifying an argument on the command line vs with the -@ option is that the arguments are processed by the command shell on the command line.  See FAQ 18 for my understanding of how the Windows command shell handles special characters.

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

jcubed

Thank you for answering.

I followed the instructions to use the chcp 65001, and it produces a different error, but still not working:

C:\WINDOWS\System32>chcp 65001
Active code page: 65001

C:\WINDOWS\System32>exiftool -stay_open true -@ -
-j
D:\ą ę\a.JPG
-execute
    1 directories scanned
    0 image files read
Not valid file comeNot valid file come{ready}

C:\WINDOWS\System32>exiftool -stay_open true -@ -
-j
-charset
filename=utf8
D:\ą ę\a.jpg
-execute
    1 directories scanned
    0 image files read
Not valid file come{ready}


The file is correct as it works from command line.

As of the solution to use a file as an input, I'm wary of using this solution, because I'm trying to fix up another project which is using exiftool (elodie) (although sortphotos also failed for me with special characters which also uses exiftool), and while debugging it I found exiftool with special characters to be the root of the problem. So I don't think it would make sense to use a file as input when using a script, correct me if I'm wrong.

Anyway, I remembered I have WSL. Works fine on it lol.

Phil Harvey

Try putting the filename in a UTF-8 text file, then use -charset filename=utf8 -@ TEXTFILE instead of -@ -.

I don't know how Windows mangles stdin, so I can' t vouch for which character set you should be using with -@ -.

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