batch append not working - DOS

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: batch append not working - DOS

Post by snibgo »

Code: Select all

 IF  EXIST  %ZERO%  GOTO  APPEND1

:APPEND1
for %%f in (%ZERO%) do set BYTE=%%~zf
If %ZERO% exists, we goto the next statement, which would happen anyway.

What do you think will happen if %ZERO% doesn't exist?
snibgo's IM pages: im.snibgo.com
FlyingJenny2bucks
Posts: 22
Joined: 2015-03-01T19:40:59-07:00
Authentication code: 6789

Re: batch append not working - DOS

Post by FlyingJenny2bucks »

I modified it and the dos window simply exited without executing the commands. Is there a way to show precisely which step is causing the problem?
Set FILESIZE=1000000

For %%a in (*.jpg) do (
Set ZERO=Blues\%%~na-007-a.jpg
for %%f in (%ZERO%) do set BYTE=%%~zf
IF %BYTE% LEQ %FILESIZE% (
convert Blues\%%~na-007-a.jpg Blues\%%~na-007-b.jpg Blues\%%~na-007-c.jpg Blues\%%~na-007-d.jpg -background grey +append Done\%%~na.jpg
) ELSE (
convert Blues\%%~na-007-a.jpg Blues\%%~na-007-b.jpg Blues\%%~na-007-c.jpg Blues\%%~na-007-d.jpg -background grey -append Done\%%~na.jpg
)
)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: batch append not working - DOS

Post by snibgo »

... the dos window simply exited without executing the commands.
No commands were executed at all? I don't believe that.

After you set the value of BYTE, test the value with

Code: Select all

echo %BYTE%
Then learn about "delayed expansion".
snibgo's IM pages: im.snibgo.com
FlyingJenny2bucks
Posts: 22
Joined: 2015-03-01T19:40:59-07:00
Authentication code: 6789

Re: batch append not working - DOS

Post by FlyingJenny2bucks »

echo is showing %BYTE% as nothing.
for %%f in ((NULL)) do set BYTE=%%~zf
echo
Edit: I found the problem. Its the bloody parenthesis ().

I have to rearrange the code to exclude the parenthesis.

Code: Select all

For %%a in (*.jpg) do Set ZERO=Blues\%%~na-007-a.jpg
For %%f in (%ZERO%) do set BYTE=%%~zf
FlyingJenny2bucks
Posts: 22
Joined: 2015-03-01T19:40:59-07:00
Authentication code: 6789

Re: batch append not working - DOS

Post by FlyingJenny2bucks »

I've rearranged the code below but it says "convert.exe: unable to open image " Blues\%%~na-007-a.jpg". No such file or directory."

Code: Select all

Set FILESIZE=1000000

For %%a in (*.jpg) do Set ZERO=Blues\%%~na-007-a.jpg
For %%f in (%ZERO%) do set BYTE=%%~zf
IF %BYTE% LEQ %FILESIZE% GOTO APPEND1 ELSE GOTO APPEND2

:APPEND1
convert Blues\%%~na-007-a.jpg Blues\%%~na-007-b.jpg Blues\%%~na-007-c.jpg Blues\%%~na-007-d.jpg -background grey +append Done\%%~na.jpg

:APPEND2
convert Blues\%%~na-007-a.jpg Blues\%%~na-007-b.jpg Blues\%%~na-007-c.jpg Blues\%%~na-007-d.jpg -background grey -append Done\%%~na.jpg
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: batch append not working - DOS

Post by snibgo »

Your questions are now entirely about scripting, rather than ImageMagick. I suggest you find a book or website devoted to that topic.
snibgo's IM pages: im.snibgo.com
Post Reply