out" (add comment) in a batch/cmd?

This question already has an answer here:

  • Which comment style should I use in batch files? 9 answers

  • The rem command is indeed for comments. It doesn't inherently update anyone after running the script. Some script authors might use it that way instead of echo , though, because by default the batch interpreter will print out each command before it's processed. Since rem commands don't do anything, it's safe to print them without side effects. To avoid printing a command, prefix it with @ , or, to apply that setting throughout the program, run @echo off . (It's echo off to avoid printing further commands; the @ is to avoid printing that command prior to the echo setting taking effect.)

    So, in your batch file, you might use this:

    @echo off
    REM To skip the following Python commands, put "REM" before them:
    python foo.py
    python bar.py
    

    using :: (alternative to REM )

    your codes
    ::   commenttttttttttt 
    your codes
    REM  commenttttttttttt 
    

    Notes:

  • using :: might cause different errors in nested logic ( IF-ELSE , FOR loops, etc...), and you can try to use the code-standard REM in most cases.

  • You need to add & sign if you wish to put the comment at the same line of the code: & :: commenttttttttttt

  • Must be put at the end of the line as all languages do.

  • ps I have no idea why the inventors couldn't find a better symbol than REM .


    No, plain old batch files use REM as a comment. ECHO is the command that prints something on the screen.

    To "comment out" sections of the file you could use GOTO . An example of all these commands/techniques:

    REM it starts here the section below can be safely erased once the file is customised
    ECHO Hey you need to edit this file before running it!  Check the instructions inside
    ECHO Now press ctrl-c to interrupt execution or enter to continue
    PAUSE
    REM erase the section above once you have customised the file
    python executed1.py
    ECHO Skipping some stuff now
    GOTO End
    python skipped1.py
    python skipped2.py
    :END
    python executed2.py
    

    What can I say? batch files are a relic of times long gone, they're clunky and ugly.

    You can read more on this website.

    EDIT: modified the example a bit to have it contain the elements you are apparently looking for.

    链接地址: http://www.djcxy.com/p/3422.html

    上一篇: GitHub狠狠地砸了Markdown

    下一篇: out“(添加评论)在批处理/ cmd?