Page 1 of 1

Windows batch files?

Posted: 2009-02-22T10:23:05-07:00
by PA_Kid
Hello all,

Fmw42 was kind enough to provide some commands that I was looking for, however I'm trying to get these to work on a Windows machine using batch files. As of right now, the Unix style formatting of the commands isn't working fully, and I have a feeling it's a single quote ( ' ) vs double quote ( " ) issue.

Here's the original link: viewtopic.php?f=1&t=13180&start=0

Here's what I'm working with so far:

Code: Select all

set color="convert test.jpg -format '%%[pixel:s.p{0,0}]' info:"
convert test.jpg -background "%color%" -gravity center -splice 0x60 -gravity south -chop 0x60 test2.jpg
I changed Fmw42's Unix style variable to a DOS style variable in the first line, and then I'm attempting to call that variable in the second line with the "%color%". However, the double quotes in the second line ends up spewing out two copies of the test.jpg file - both with black space where the splice happened.

Any help would be greatly appreciated!

Re: Windows batch files?

Posted: 2009-02-22T14:37:36-07:00
by el_supremo
You didn't completely translate Fred's original command. Unfortunately, the effect of a backtick ` in UNIX can't be directly translated to DOS but Anthony has a neat workaround using the FOR command - described here

This should do what you want:

Code: Select all

FOR /F "tokens=*" %i IN ('convert test.jpg -format "%[pixel:s.p{0,0}]" info:') DO convert test.jpg -background %i -gravity center -splice 0x60 -gravity south -chop 0x60 test2.jpg
Pete

Re: Windows batch files?

Posted: 2009-02-23T22:04:04-07:00
by anthony
The credit for that neat trick is to Thorsten Röllich (address withheld)