Translate a Shell script into Windows Batch file

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?".
Post Reply
T2ioTD
Posts: 12
Joined: 2016-09-04T09:31:38-07:00
Authentication code: 1151

Translate a Shell script into Windows Batch file

Post by T2ioTD »

Hi

Would you please assist me to turn this shell script (kindly written by fmw42) into a batch file:

cd
cd desktop/test1
imgname="rose"
arr=(`ls ${imgname}*.png`)
numimg=${#arr[*]}
num=`echo "scale=0; $numimg/2" | bc`
for ((i=0; i<num; i++)); do
j=$((2*i+1))
k=$((j+1))
convert ${imgname}$j.png ${imgname}$k.png +append ../test2/${imgname}${j}_${k}.png
done
cd

My intent is to drag and drop a number of images (or a folder containing images? this still confuses me)
into the batch file, so that images are joined two by two (side by side).

Note: i will be absent for a couple of days, so please do not be offended if I do not reply promptly...
Jean-Pierre Coulon
Posts: 41
Joined: 2016-10-04T02:08:22-07:00
Authentication code: 1151
Location: Nice, France

Re: Translate a Shell script into Windows Batch file

Post by Jean-Pierre Coulon »

I would rather write a Fortran creating the series of DOS commands, but try the newsgroup alt.msdos.batch
Jean-Pierre Coulon
Posts: 41
Joined: 2016-10-04T02:08:22-07:00
Authentication code: 1151
Location: Nice, France

Re: Translate a Shell script into Windows Batch file

Post by Jean-Pierre Coulon »

I put myself to the problem: create the batch assoctab.bat with

for /L %%a in (1, 1, %1) do (
(set /a ileft="2*%%a-1")
(set /a iright="2*%%a")
call convert rose%%ileft%%.png rose%%iright%%.png +append tulip%%ileft%%_%%iright%%.png)

Type assoctab <number of initial png files>

Hope you will be able to adapt it.
karlw
Posts: 5
Joined: 2016-10-12T01:35:48-07:00
Authentication code: 1151

Re: Translate a Shell script into Windows Batch file

Post by karlw »

For files:

Code: Select all

@echo off
chcp 65001
cd /d "%~dp0"
md Append2
magick %*% +append ^
	"./Append2/result%random%.png"
exit
for folders:

Code: Select all

@echo off
chcp 65001
cd /d "%~dp0"
md Append2
magick %*%/*.png ^
	+append ^
	"./Append2/result%random%.png"
exit
i append litle archive for you with ready and tested batch-s and one file its kind of demo that can realy help you
andestend how win cmd work. just drag on batch named files and folders and see.
if you need adapt batch-s to specific needs (i mean administrator staff not IM) i try to help you.
here worked solution and demo files: http://rgho.st/7F2wXHVwl
Post Reply