Page 1 of 1

Translate a Shell script into Windows Batch file

Posted: 2016-10-04T09:41:58-07:00
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...

Re: Translate a Shell script into Windows Batch file

Posted: 2016-10-05T04:08:34-07:00
by Jean-Pierre Coulon
I would rather write a Fortran creating the series of DOS commands, but try the newsgroup alt.msdos.batch

Re: Translate a Shell script into Windows Batch file

Posted: 2016-10-10T07:19:47-07:00
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.

Re: Translate a Shell script into Windows Batch file

Posted: 2016-10-13T23:34:37-07:00
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