Gimp-Forum.net
Invalid char set error when trying to batch convert files - Printable Version

+- Gimp-Forum.net (https://www.gimp-forum.net)
+-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP)
+--- Forum: General questions (https://www.gimp-forum.net/Forum-General-questions)
+--- Thread: Invalid char set error when trying to batch convert files (/Thread-Invalid-char-set-error-when-trying-to-batch-convert-files)



Invalid char set error when trying to batch convert files - Zentian - 05-29-2022

I'm trying to batch convert some images and am getting an invalid char set error when I do. I'm on Windows 10 and I'm using.

myconverter.scr in %AppData%/Roaming/Gimp/2.10/scripts/

Code:
(define (myconvert in_filename out_filename)
    (let* (
            (image (car (gimp-file-load RUN-NONINTERACTIVE in_filename in_filename)))
            (drawable (car (gimp-image-get-active-layer image)))
        )
        (file-heif-save RUN-NONINTERACTIVE image drawable out_filename out_filename 0 0)
    )
)

then a .bat file

Code:
 for /r %%i in (*.jpg) ; do "C:\Program Files\GIMP 2\bin\gimp-2.10.exe" -i -b '(myconvert "%%i" "%%i.HEIF")' -b '(gimp-quit 0)' ; done

It looks like it's able to open the image, but then prints out 

** (gimp-2.10.exe:21188): WARNING **: 19:22:33.507: Invalid charset: `InvalidCharsetId'
batch command executed successfully
batch command executed successfully

Does anyone know what the issue could be?


RE: Invalid char set error when trying to batch convert files - Ofnuts - 05-30-2022

Any non-ASCII characters in the name? Or possibly in the path to the directory where you work?


RE: Invalid char set error when trying to batch convert files - Zentian - 05-30-2022

Nope. It seems the warning may be benign though. I thought the warning was what was causing my script to hang, but that wasn't it. Turns out, it didn't like the single quotes, which I was using because escaping the double quotes didn't appear to be working. But what was actually happening was %%i evaluates to a path that contains \ which needed to be escaped. Not sure how to do that, so I just echoed all the file paths into a file, did a find replace on \ to \\, and did

Code:
for /f "tokens=*" %%i in (files.txt) do (
  "C:\Program Files\GIMP 2\bin\gimp-console-2.10.exe" -c -d -i -b "(myconvert \"%%i\" \"%%i.HEIC\")" -b "(gimp-quit 0)"
 )

which seems to run now.