Cagri
Cagri

Reputation: 727

Using for loop in a specific folder using dos batch script

I would like to run executable file using the yuv files as an input in a specific folder using batch script. However, the above code that I am using run only a time and then stop. Could anyone help me?

>  SET /A COUNT=1
>     for /r "F:\coding\Wetlands_1920x1080p\" %%v in (*.yuv) do (
>           TAppEncoder.exe -c EBU.cfg -f 30 -i "%%v" -wdt 1920 -hgt 1080 -o %COUNT%.yuv >%COUNT%.txt
>           SET /A COUNT+=1
>           )

Upvotes: 0

Views: 53

Answers (1)

Magoo
Magoo

Reputation: 80193

setlocal enabledelayedexpansion
SET /A COUNT=1
for /r "F:\coding\Wetlands_1920x1080p\" %%v in (*.yuv) do (
       TAppEncoder.exe -c EBU.cfg -f 30 -i "%%v" -wdt 1920 -hgt 1080 -o !COUNT!.yuv >!COUNT!.txt
  SET /A COUNT+=1
)

Within a block (a parenthesised series of statements) %var% refers to the value of var when the block was parsed. To access the run-time value, you need to invoke delayedexpansion and then use !var! to retrieve the required value.

See any number of SO items on the delayedexpansion problem. (it's very common...)

Upvotes: 2

Related Questions