Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question
add comment

4 Answers

up vote 5 down vote accepted

:: (also called comment label) is a comment just as REM is.

There are some differences between them. The main ones are:

  • With ECHO ON a REM line is showed 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).
  • Labels and :: have a special logic and can cause problems in parenthesis blocks - take care when using them inside ( ).
share|improve this answer
add comment

A line that start in double colon represent an invalid label that is ignored by the command processor, so it may be used to insert a comment. For reasons that can't be traced, many people use :: to insert comments in Batch files, but you must be aware that there are several pitfalls in its use that are described in the link given in Koterpillar's answer. It seems that the first use of :: instead of REM command was with the purpose to speed up the execution of Batch files in slow machines (ie: floppy disks), but that reason is not a valid justification for the use of double colon since many years ago.

Any line that contain an invalid label will be ignored by the command processor and you may use practically any special character to generate an invalid label. For example:

@echo off

:~ This is a comment
:` This is a comment
:! This is a comment
:@ This is a comment
:# This is a comment
:$ This is a comment
:% This is a comment
:^ This is a comment
:& This is a comment
:* This is a comment
:( This is a comment
:) This is a comment
:_ This is a comment
:- This is a comment
:+ This is a comment
:= This is a comment
:{ This is a comment
:} This is a comment
:[ This is a comment
:] This is a comment
:| This is a comment
:\ This is a comment
:: This is a comment
:; This is a comment
:" This is a comment
:' This is a comment
:< This is a comment
:> This is a comment
:, This is a comment
:. This is a comment
:? This is a comment
:/ This is a comment

echo OK
share|improve this answer
add comment

A line starting with a colon is a label which you can jump to with goto:

goto end
:end

A line starting with a double colon is a label, except you can't, even accidentally, jump to it:

goto :end REM this doesn't work
::end

Thus, double colon is used to comment lines out.

Source: http://www.robvanderwoude.com/comments.php

share|improve this answer
add comment

The colon (:) is a label marker and can be used for got instructions.

Some people use : as a comment too so a double colon is simply a stylistic REM statement

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.