Python Plugin from .bat - 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) +--- Thread: Python Plugin from .bat (/Thread-Python-Plugin-from-bat) |
Python Plugin from .bat - Eonwe - 02-01-2022 Hello Folks, I am trying to call a Python Script from a Windows batch file, but somehow I can't get it to work. All I ever got was "batch execution failed". I am certain that the problem lies within the .bat file that I use to call the script. Can someone please tell me the right syntax? Code: REM switch to GIMP folder I am pretty sure the problem is with the escaped quotes but I don't know how to change that and I couldn't find a working example anywhere. The example is taken from here and untouched except the modified quotes: http://gimpchat.com/viewtopic.php?f=9&t=15024 Thanks in advance! RE: Python Plugin from .bat - Kevin - 02-01-2022 Where have you put save2png.py ? because you're expecting the import save2png to be able to find it. Your GIMP installation directory is somewhat unusual as well. RE: Python Plugin from .bat - Ofnuts - 02-01-2022 Change your escaped quotes to single quotes. And answer Kevin's questions. But if it just to convert between file formats, ImageMagick is normally a much better option. RE: Python Plugin from .bat - Eonwe - 02-01-2022 (02-01-2022, 03:56 PM)Kevin Wrote: Where have you put save2png.py ? because you're expecting the import save2png to be able to find it. save2png.py is in the same path as the .bat, because I guessed that's what sys.path=['.']+sys.path is supposed to do. To be honest I am not completely sure, what it does. I also tried to link there with sys.path.append(%~dp0) but to no avail. It's a portable installation, therefore the strange install dir. (02-01-2022, 04:04 PM)Ofnuts Wrote: Change your escaped quotes to single quotes. And answer Kevin's questions. But if it just to convert between file formats, ImageMagick is normally a much better option. I thought that single quotes are not allowed in command lines, but I will try. Thanks for the input! No, it's not just for conversion, that's just the most simple example I could find to test the call from .bat. RE: Python Plugin from .bat - Eonwe - 02-03-2022 Code: cd C:\Users\wa2378\AppData\Local\Programs\GIMP 2\bin this is what did the job for me. path.append to find the module, double slashes in the directory name and the strings called with single quotes. Thanks for your help! |