Run batch command line in Fu console beginning with 'gimp' - Printable Version +- Gimp-Forum.net (https://www.gimp-forum.net) +-- Forum: GIMP (https://www.gimp-forum.net/Forum-GIMP) +--- Forum: Extending the GIMP (https://www.gimp-forum.net/Forum-Extending-the-GIMP) +---- Forum: Scripting questions (https://www.gimp-forum.net/Forum-Scripting-questions) +---- Thread: Run batch command line in Fu console beginning with 'gimp' (/Thread-Run-batch-command-line-in-Fu-console-beginning-with-gimp) |
Run batch command line in Fu console beginning with 'gimp' - Gimpnik - 09-23-2022 If I run the following code in Fu console Code: (gimp -i -b '(batch-crop-to-content "D:\Test\*.png")') or Code: (gimp -b '(batch-crop-to-content "D:\Test\*.png")') so I receive the following error message: Code: Error: syntax error: illegal token 1 Please help to understand this error. I would like to run the command line via a batch script, but I receive only "batch command executed successfully" and cant' see more details. How to force detailed output for gimp-2.10.exe console without "echo off" to be able to see for possible errors in the chain of procedures? In the batch script I have explicitly set "echo on" but this not help here, because gimp-2.10.exe is started as a separate process. Thanks RE: Run batch command line in Fu console beginning with 'gimp' - PixLab - 09-24-2022 maybe try to start GIMP from terminal* with --verbose Code: gimp --verbose in all case Code: man gimp [attachment=8731] EDIT * I just saw you're on Microsoft's Windows, commands above are for Linux/MacOS, you might need to adapt those command for your OS RE: Run batch command line in Fu console beginning with 'gimp' - Gimpnik - 09-24-2022 Thanks. In the meantime I have figured it out: With the parameter --verbose I get the detailed output on the Gimp console - this works fine, however absolutely no errors are listed. But attention: This parameter can be placed only before the parameter -b! Otherwise it will proceed the script with vebose output but leads on the end to error: Code: Error: eval: unbound variable: --verbose It seems to be a bug. And abbreviations like -v or --v are not supported! Or more precisely -v does something completely different and indeed shows the versions of the Gimp modules without to process the rest of the code on the same command line. However, I haven't found out yet how the command line is to be inserted directly in the Fu console, so that I can at least try it out there to see if it so finally starts up. On the other hand via the GUI menu the both commands - "crop to content" (early "auto crop, before Gimp v.2.10) and "zealous crop" - works fine and the same pictures are processed without any problems. A very strange thing. Enclosed is a summary of everything - perhaps anyone will notice the error: batch-crop-to-content.scm: Code: (define (batch-crop-to-content pattern) or analogously for batch zealous crop: batch-zealous-crop.scm Code: (define (batch-zealous-crop pattern) And in batch script it is like: Code: @echo on (resp. for zealous crop with adjusted line: '(batch-zealous-crop "*.png")' instead of '(batch-crop-to-content "*.png")') And again: via batch script everything is executed without errors, but the *.png files (that are of course in the same directory of the batch scripts) are not processed but the same pictures are processed with the both commands via the GUI. RE: Run batch command line in Fu console beginning with 'gimp' - Ofnuts - 09-24-2022 gimp -i -b '(batch-crop-to-content "D:\Test\*.png") is a shell/terminal command that calls Gimp, not a script-fu instruction. You cannot use it in the script-fu console. Gimp batch is executed by calling Gimp from a terminal (gimp -i -b, and giving it a script-fu/python-fu script to execute ('(batch-crop-to-content "D:\Test\*.png")'). To make things even more confusing the syntax of shell commands (in particular, relative to single quotes and double quotes) is different between Windows and Unix (Linux and OSX) so make sure you follow examples for the proper OS. RE: Run batch command line in Fu console beginning with 'gimp' - rich2005 - 09-24-2022 As ofnuts states syntax between linux and Windows. This works in linux batch-autocrop.scm in Gimp script folder Code: (define (batch-autocrop pattern) and in a terminal Code: gimp -i -b '(batch-autocrop "*.png" )' -b '(gimp-quit 0)' Basically what is given in the Gimp docs. Tried all ways in a Win10 VM with no success, forward slashes / double (escape) slashes / various quotes). Script runs, nothing happens. How many files do you need to process ? The Gimp BIMP batch plugin works (autocrop is 'other' Gimp procedure) RE: Run batch command line in Fu console beginning with 'gimp' - Gimpnik - 09-24-2022 (09-24-2022, 12:35 PM)Ofnuts Wrote: gimp -i -b '(batch-crop-to-content "D:\Test\*.png") is a shell/terminal command that calls Gimp, not a script-fu instruction. You cannot use it in the script-fu console.Clear statement! (09-24-2022, 12:35 PM)Ofnuts Wrote: Gimp batch is executed by calling Gimp from a terminal (gimp -i -b, and giving it a script-fu/python-fu script to execute ('(batch-crop-to-content "D:\Test\*.png")'). If you mean script-fu instruction would be only this part, so it does not work like that either directly in fu console: Code: (batch-crop-to-content "D:\Test\*.png") I receive: Code: > (batch-crop-to-content "D:\Test\*.png") (09-24-2022, 12:35 PM)Ofnuts Wrote: To make things even more confusing the syntax of shell commands (in particular, relative to single quotes and double quotes) is different between Windows and Unix (Linux and OSX) so make sure you follow examples for the proper OS. Yes, and here you are absolutely right! The solution is with the following syntax (in Windows Batch scripts each double quote of the inside pair must be escaped and depending on this usually succeeds with the character "\", so that this part can be passed as one argument correctly and not fragmented in many wrong arguments): Code: gimp -i -b "(batch-crop-to-content \"*.png\")" -b "(gimp-quit 0)" and finally it works ! Thanks Conclusion: I already realize that as a Windows (and not Ubuntu … Linux) user I will experience a lot of stumbling traps here. I wonder now why it is "as batch script" with wrong syntax everywhere in many posts/blogs, and I just blindly relied on it being correct in any case, however, from now on I will pay more attention. RE: Run batch command line in Fu console beginning with 'gimp' - Ofnuts - 09-25-2022 (09-24-2022, 09:07 PM)Gimpnik Wrote:(09-24-2022, 12:35 PM)Ofnuts Wrote: gimp -i -b '(batch-crop-to-content "D:\Test\*.png") is a shell/terminal command that calls Gimp, not a script-fu instruction. You cannot use it in the script-fu console.Clear statement! Well if you want to learn a bit of Python there are working examples out there. RE: Run batch command line in Fu console beginning with 'gimp' - Gimpnik - 09-25-2022 Thanks |