Page 1 of 1

Multi-line Syntax (cmd)

Posted: 2015-04-03T13:35:18-07:00
by afre
Continued from this discussion. snibgo, how would you make this arbitrary code more readable?

Code: Select all

FOR %j in (045 155) DO FOR %k in (050 150) DO convert rose: -resize 500% -modulate %j,%k,100 rose%j%k.png
Could easily add another loop by substituting rose: with %i for batch image processing.

Re: Multi-line Syntax (cmd)

Posted: 2015-04-03T14:27:22-07:00
by snibgo
As a command typed into the console, I wouldn't split it. I can't see any point in splitting it.

If in a BAT script, so each % must be doubled, I might do it like this:

Code: Select all

FOR %%j in (045 155) DO FOR %%k in (050 150) DO convert ^
  rose: -resize 500%% -modulate %%j,%%k,100 rose_%%j_%%k.png
or

Code: Select all

FOR %%j in (045 155) DO (
  FOR %%k in (050 150) DO (
    %IM%convert ^
      rose: ^
      -resize 500%% ^
      -modulate %%j,%%k,100 ^
      rose_%%j_%%k.png
  )
)
I have also put underscores _ in the output filename.

I generally split convert commands so each input, output, and unit of processing is on a separate line.

Re: Multi-line Syntax (cmd)

Posted: 2015-04-03T23:51:04-07:00
by afre
I do try to figure things out but could you elaborate on this?
snibgo wrote:

Code: Select all

for /F "usebackq" %%L in (`convert ^
  infile ^
  {procesing} ^
  outfile`) do {something}

Re: Multi-line Syntax (cmd)

Posted: 2015-04-04T02:35:53-07:00
by snibgo
See examples in my scripts, such as http://im.snibgo.com/eqlimit.htm#eqLimit.bat

Re: Multi-line Syntax (cmd)

Posted: 2015-04-04T11:02:49-07:00
by afre
snibgo wrote:These days, my usual syntax is something like: for /F "usebackq" %%L in (`convert ^
....
See examples in my scripts, such as http://im.snibgo.com/eqlimit.htm#eqLimit.bat
My impression is that it pipes the output from one command to another; in your examples, it's used to ECHO results or set them to a local variable. I guess I'm also trying to figure out how it relates to my previous question regarding indentation, etc.

Anyway, this is what I was looking for, thanks.