0

I have a BAT procedure CONVTS that executes the following code:

...
) Else (

    ::Process single file --------
    echo.Single file processing

    setlocal EnableDelayedExpansion
    set "input=%lib1%%1%ext1%"
    set "output=%lib1%%1.mp4"
    echo.Process single file - "!input!" - "!output!"
    call :Convert "!input!" "!output!"

)

It runs fine so far ... this is the (expected) output:

"C:\Userlink\ffmpeg\bin\convts.bat" test has started ...
Single file processing
Process single file - "P:\Convert\test.ts" - "P:\Convert\test.mp4"

But if I remove echo.Single file processing, I get the following error:

"C:\Userlink\ffmpeg\bin\convts.bat" test has started ...
The syntax of the command is incorrect.

I have no idea what could be wrong about removing the echo command !

This behaviour seems very strange to me ... most probably I lack some important info about the syntax of BAT procedures.

I hope somebody can help me out ...

Stephan
  • 53,940
  • 10
  • 58
  • 91
Peter329
  • 11
  • 4
  • 1
    No labels allowed inside a code block. `:: blabla` is a (malformed) label. Use `REM` instead of `::` for comments (as best practice not only in code blocks but generally) – Stephan Jan 16 '22 at 09:29
  • 1
    (oh and by the way: `dos` is a tag intended for MS-DOS (the ancient command-line based operating system from the nineteen-seventies (before Windows was a thing). The thing that is (wrongly) named "DOS-Box" in Windows is the "Windows Command Line". The correct tag for it is `cmd` (and/or `batch-file`)) – Stephan Jan 16 '22 at 09:33
  • 1
    If you are interested in the details of `REM` vs. `::`, see [here](https://stackoverflow.com/a/12407934/2152082) – Stephan Jan 16 '22 at 09:41
  • @Stephan: Thanks A LOT ! So using :: is definitely not a good idea - I did not know that. I had looked for that error for hours, you really made my day ! And of course I will use the Tag "cmd" from now on ! – Peter329 Jan 16 '22 at 10:06
  • By the way, never use [`echo.`](https://ss64.com/nt/echo.html); in your situation `echo` + _space_ is perfectly fine. Anyway, the best way to echo a blank line is `echo/`, the safest way to echo anything unknown is `echo(!VAR!`… – aschipfl Jan 16 '22 at 16:20
  • Also take a look at [this related post on DosTips.com](https://www.dostips.com/forum/viewtopic.php?p=56030#p56030)… – aschipfl Jan 16 '22 at 16:55

0 Answers0