3

I have a script based on GIMP batch tutorial:

  (define (batch-colorize pattern
                              hue
                              saturation
                              lightness)
  (let* ((filelist (cadr (file-glob pattern 1))))
    (while (not (null? filelist))
           (let* ((filename (car filelist))
                  (image (car (gimp-file-load RUN-NONINTERACTIVE
                                              filename filename)))
                  (drawable (car (gimp-image-get-active-layer image))))
             (gimp-colorize drawable
                            hue saturation lightness)
             (gimp-file-save RUN-NONINTERACTIVE
                             image drawable filename filename)
             (gimp-image-delete image))
           (set! filelist (cdr filelist)))))

So now in the folder with my images with cmd I run:

SET gimpEXE="C:\Program Files\GIMP 2\bin\gimp-2.8.exe"

%gimpEXE% -i -b "(batch-colorize *.png 90 73 15)" -b "(gimp-quit 0)";

But then GIMP says:

batch command experienced an execution error:

Error: ( : 1) eval: unbound variable: *.png

So then I tried:

%gimpEXE% -i -b "(batch-colorize ""*.png"" 90 73 15)" -b "(gimp-quit 0)";

But then GIMP says:

GIMP-Error: Failed to open file C:\myfolder\with\png\90: No such file or directory

GIMP-Error: Failed to open file C:\myfolder\with\png\73: No such file or directory

GIMP-Error: Failed to open file C:\myfolder\with\png\15: No such file or directory

GIMP-Error: Failed to open file C:\myfolder\with\png\0: No such file or directory

So then I tried what was in an original example (witch I assume is for Linux):

%gimpEXE% -i -b '(batch-colorize "*.png" 90 73 15)' -b '(gimp-quit 0)'

But then GIMP says all above and:

GIMP-Error: Failed to open file "C:\myfolder\with\png*.png": Unable to open "C:\myfolder\with\png*.png" for reading: Invalid argument

1 Answer 1

4

You're assuming that the OS is going to expand the *.png for you, but since it's buried inside the quoted string for the command line argument, the expansion won't happen. This should fix the issue:

SET gimpEXE="C:\Program Files\GIMP 2\bin\gimp-2.8.exe"
for %%i in (*.png) do %gimpEXE% -i -b "(batch-colorize %%i 90 73 15)" -b "(gimp-quit 0)"

Note that the %%i is only necessary if this is contained in a batch file. If you're running the command directly at the prompt, %i is required instead.

1
  • Actually I was hoping GIMP would expand *.png. Eventually I used the same (original) command to parse those files, but in GIMP console. But I guess both ways work.
    – Nux
    Sep 26, 2013 at 0:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .