I want to know how to comment in a Windows batch file/bat file. I’d also like to know batch script commands and how to do batch scripts for loops and how to use a batch script to rename files in a folder. I have also seen an error that says “batch script contains dos line breaks” and would like to know how to fix it. Resolution:
Microsoft Windows uses batch file comments, also known as batch scripts, which are text files saved with the .bat extension. These text files contain commands to be executed by the Command Prompt/Windows Terminal. You can write one of these text files using some of Windows most basic built-in appliations such as Notepad or Notepad++.
How to Make Comment in Batch Script
You can create comments in batch scripts two ways: using the
Rem command or the
:: command. Any text that follows the
:: commands will be perceived as comments and thus will not be excuted commands. This means you can add comments to help you reference your code. Here is how to do that:
An example of making a comment with Rem and the double colon:
Rem This comment will not be printed
:: This comment will not be printed
An example of leaving an inline comment:
echo <the code> & :: This command prints <the code>
echo <the code> REM This command prints <the code>
Note: Replace the words
<the code> with the actual code that you want to use.
You can also use Goto to direct an cmd.exe to a labeled line in a batch program. The batch program directs the command to a line that is identified with a label.
- How to Run Windows Grep Equivalent? [Q&A]
- How to Fix Windows 10 Black Screen with Cursor Before/After Login? [Q&A]