What does :: (double colon) mean in DOS batch files?

user310291 picture user310291 · May 19, 2013 · Viewed 36.2k times · Source

I found this program http://baiyunmanor.com/blog/work/get-current-date-time-in-dos-batch-file/

But I don't know what does the line

:: datetime.bat

at the end mean?

Answer

acdcjunior picture acdcjunior · May 19, 2013

:: is a label (also, inaccurately, known in the wild by comment label) can be, in practice, considered a comment just as REM is, as it is an "un-goto-able" label.

There are some differences between REM and ::, though. The main ones are:

  • With ECHO ON a REM line is shown but not a line commented with ::
  • A :: can execute a line end caret (that is, a ^ at the end of a line starting with :: makes the next line also a comment):

    :: This is a comment^
    echo but watch out because this line is a comment too
    
  • Labels and :: have a special logic and can cause problems in parentheses blocks - take care when using them inside ( ). Example:

    for %%D in (hi) do (
        echo Before...
        :: My comment
        :: Some other comment
        echo After...
    )
    

    Outputs:

    Before ...
    The system cannot find the drive specified.
    After...