E
E
Eugene2016-01-16 14:36:10
cmd/bat
Eugene, 2016-01-16 14:36:10

Why don't variables work in bat file?

In general, here is such a batch file

::исходный и результирующий файлы
set src = %1
set out = %2

::стартовые секунда, минута и час
set /a sh = %3
set /a sm = %4
set /a ss = %5

::конечные секунда, минута и час
set /a eh = %6
set /a em = %7
set /a es = %8

if %ss% LSS %es% (
    set /a ts = %es% - %ss%
) else (
    set /a ts = 60 - %ss% + %es%
)

if %sm% LSS %em% (
    set /a tm = %em% - %sm%
) else (
    set /a tm = 60 - %sm% + %em%
)

set /a th = %eh% - %sh%

ffmpeg.exe -ss 3 -i %src% -c:a copy -c:v copy -map 0 -y -t 5 %out%

Until the last line, everything seems to be fine, no errors are thrown. The point is that in the last line, no values ​​are substituted for %src% and %out% . ffmpeg.exe appears on the command line
-ss 3 -i -c:a copy -c:v copy -map 0 -y -t 5
That is, holes in the places where the values ​​of these variables should be. ea099e9d764e48e3bb406cafceae1c27.jpg
I'm trying to echo %out% to the screen, it says "Output mode (ECHO) enabled" instead of showing the contents of the out variable.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Olgeir, 2016-01-19
@tw1ggyz

Remove before and after = -+ spaces.
not
set src = %1
but
set src=%1
not
set /a th = %eh% - %sh%
but
set /a th=%eh%-%sh%
and everything will work

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question