I am trying to build a Windows batch file which should do the following:
- Take the reference image (it should be the first image by taking into account the numeration
ima_0001.png
,ima_0002.png
...). - In the second step, the
FOR
structure takes the images in the sequence (e.g.:ima_0001.png
,imag_002.png
, ...), calls a function to compare images from another batch file, and updates the reference image with the current image%defa%
.
The script performs nearly well except for two major steps:
I can't set the reference or first file directly with
set "defa=ima_0001.png"
I tried in different ways:defa=ima_0001.png
,defa=!ima_0001.png!
, without success.
So finally I decided to leave theFOR
structure selecting one which does not coincide with the first numbered (it takesima_0064.png
and notima_0001.png
)
I thank somebody who can help me to set the first one whether manually or automatically.The worst part is that the second
FOR
structure does not change the reference image with the lineset "defa=%%h"
.
For example, after the first cycleFOR
,defa
should change fromima_0001.png
toima_0002.png
, or fromima_0064.png
toima_0065.png
. However, when console runs,%%h
changes, butdefa
always shows the first image, (ima_0064.png
). I also tried different ways without success, as well as settingsetlocal
or not setting it.
I thank somebody who can give me notions to solve his issue.
The script is:
@echo off
setlocal enabledelayedexpansion
cd C:\Users\docs
set/a "th=870"
REM Set the first file or take one with FOR
::set "defa=ima_0001.png"
FOR %%m in (1,1,*.png) do set "defa=%%m"
REM BUCLE DE LLAMADA A LA FUNCIÓN Callme
FOR %%h in (*.png) DO (
Callme "%defa%" "%%h" %th%
set "defa=%%h"
)
pause