简体   繁体   中英

My windows batch says: “72 was unexpected at this time.”

My batch file below, creates an .avs file for given list of parameters and then runs a program which takes this .avs file as an argument and does this multiple times in a for loop.

But when I run my batch file, it prints 72 is unexpected at this time. , 72 is value of one of the parameters. The .avs file is not created and the program is not executed.

My batch file and its output on command prompt with REM @echo off is below.

My batch file:

REM @echo off

set RawSource26=C:\_rawsource26\RawSource26.dll
set avsFile=.\temporary.avs
set avs2yuv=C:\_avs2yuv\avs2yuv.exe

set video=balloons
set views=^
1 ^
2 ^
3 ^
4 ^
5
set rates=^
1Mbps ^
2Mbps ^
3Mbps ^
4Mbps ^
5Mbps
set width=1024
set height=768
set cropLeft=72
set cropTop=0
set cropRight=0
set cropBottom=0

(for %%v in (%views%) do (
  @echo. 2> %avsFile%
  @echo LoadPlugin("%RawSource26%") >> %avsFile%
  @echo Crop(RawSource(".\renderOut\%video%_%%v_synth.yuv", %width%, %height%, "i420"), %cropLeft%, %cropTop%, %cropRight%, %cropBottom%) >> %avsFile%
  %avs2yuv% %avsFile% -raw -o .\avsOut\%video%_%%v_synth_avs.yuv
  (for %%r in (%rates%) do (
    @echo. 2> %avsFile%
    @echo LoadPlugin("%RawSource26%") >> %avsFile%
    @echo Crop(RawSource(".\renderOut\%video%_%%v_%%r_synth.yuv", %width%, %height%, "i420"), %cropLeft%, %cropTop%, %cropRight%, %cropBottom%) >> %avsFile%
    %avs2yuv% %avsFile% -raw -o .\avsOut\%video%_%%v_%%r_synth_avs.yuv
))))

REM del %avsFile%

My command prompt:

C:\SAFAS\folder02>avs.bat

C:\SAFAS\folder02>REM @echo off

C:\SAFAS\folder02>set RawSource26=C:\_rawsource26\RawSource26.dll

C:\SAFAS\folder02>set avsFile=.\temporary.avs

C:\SAFAS\folder02>set avs2yuv=C:\_avs2yuv\avs2yuv.exe

C:\SAFAS\folder02>set video=balloons

C:\SAFAS\folder02>set views=1 2 3 4 5

C:\SAFAS\folder02>set rates=1Mbps 2Mbps 3Mbps 4Mbps 5Mbps

C:\SAFAS\folder02>set width=1024

C:\SAFAS\folder02>set height=768

C:\SAFAS\folder02>set cropLeft=72

C:\SAFAS\folder02>set cropTop=0

C:\SAFAS\folder02>set cropRight=0

C:\SAFAS\folder02>set cropBottom=0
72 was unexpected at this time.
C:\SAFAS\folder02>  @echo Crop(RawSource(".\renderOut\balloons_%v_synth.yuv", 1024, 768, "i420"), 72, 0, 0, 0) >> .\temporary.avs
C:\SAFAS\folder02>

循环中的)实际上不是“关闭”,而是部分echo需要“转义”-然后用^)替换,否则批处理将不转义- )作为close of block

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM