Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.bat script issues
#1
Code:
@ECHO OFF
TITLE Compress GIMP
CLS

REM This is to get the first argument after the batch file
SET FILE_IN=%1
CALL :DEQUOTE FILE_IN

REM This sets the path used in the gimp script
SET PATH=%FILE_IN%\*.png

REM This prints the path
ECHO Will run GIMP script in path '%PATH%'. Press Enter to continue or Ctrl+C to exit.

REM This waits for enter input
PAUSE

REM Change argument 0 to the GIMP exe
REM For me it's "D:\Programs\GIMP 2\bin\gimp-2.8.exe" 
REM If you want to run it inside the current cmd window,
REM  use gimp-console-2.8.exe, otherwise (aka new window pops up), use gimp-2.8.exe
"D:\Programs\GIMP 2\bin\gimp-2.8.exe" -i -b "(batch-auto-fix \"%PATH%\")"

REM Tell user it's done!
ECHO DONE.
GOTO:EOF

:DEQUOTE
FOR /F "delims=" %%A IN ('echo %%%1%%') DO SET %1=%%~A
GOTO:EOF
This is a script I asked my friend to make that changes the image mode to indexed and saves it as a compressed .png. He never could get it to work and he gave up so I figured this is the best place to ask for this kind of help. I hope his comments are enough, if not I could elaborate/explain if issues arise.
Reply
#2
It is some time since I messed around with Win batch files.

Are you sure there is not an error in the script used. Is it a modified version of this? https://gist.github.com/dbuscombe-usgs/6085758.

Do you need -b '(gimp-quit 0)' tacking on the end? as:

Code:
"D:\Programs\GIMP 2\bin\gimp-2.8.exe" -i -b '(batch-auto-fix \"%PATH%\")' -b '(gimp-quit 0)'

Another way is using Imagemagick - http://www.imagemagick.org this would need wrapping in a batch file to cycle through the images. For a single image.

Code:
magick input.png png8:output.png

Something like this for a folder of images. (In a Win 7 VM)

Code:
for /r %x in (*.png) do magick "%x" "png8:%x_indexed.png"

screenshot: https://i.imgur.com/CjGw8PN.jpg

No windows expert but it seems to work Hopefully one of the Windows guys will come along.
Reply
#3
Rich - you can't use single-quotes in Windows, you have to use double quotes everywhere:

Code:
"D:\Programs\GIMP 2\bin\gimp-2.8.exe" -i -b "(batch-auto-fix \"%PATH%\")" -b "(gimp-quit 0)"
Reply
#4
(03-27-2018, 02:13 PM)Kevin Wrote: Rich - you can't use single-quotes in Windows, you have to use double quotes everywhere:

Code:
"D:\Programs\GIMP 2\bin\gimp-2.8.exe" -i -b "(batch-auto-fix \"%PATH%\")" -b "(gimp-quit 0)"

Yes, and you are the guy I was hoping would come along Wink
Reply


Forum Jump: