CMD Master
Back to Blog
Arnošt Havelka

How to Comment with REM

Add notes to your scripts that the computer ignores — but you'll thank yourself later.

Start Interactive Lesson
How to Comment with REM

How to Comment with REM

In the Windows Command Shell, a comment is a line the computer completely ignores when running your script. It's a note for you (or future you). The magic word is REM, short for Remark.

Usage:REM
[your comment here]
REM
Marks the rest of the line as a comment. The line is skipped during execution.
@REM
Same as REM, but the @ prefix also prevents the line itself from being printed to the screen.
::
A popular shorthand for comments in batch files. Slightly faster than REM.

Step 1: REM in the Terminal

Type a REM line in CMD and watch what happens:

Command Prompt
C:\Users\User>REM # My Comment

Notice: When you run REM directly in the terminal, the line is shown — it just doesn't do anything. In a .bat script, you can suppress that display with @REM.

Step 2: Silent Comments with @REM

The @ prefix tells CMD: "Don't echo this line." Combined with REM, you get a truly invisible comment.

Command Prompt
C:\Users\User>@REM # This comment is silent

Tip: Be careful about wrapping variables in quotes inside REM lines — you can accidentally double-quote things if you're not careful. @REM is the recommended style in scripts.

Step 3: The :: Shorthand

Many batch pros use :: as a faster-to-type comment marker:

Command Prompt
C:\Users\User>:: This also works as a comment

⚠️ Warning: :: can cause errors inside FOR loops or IF blocks. When in doubt, use @REM.

Step 4 — Project: Write a Commented Backup Script

Let's put it all together. Use the editor below to write (and simulate!) a fully commented batch file. Click ▶ Run to see the output, then ⬇ Download .bat to run it on your real machine.

daily_backup.bat.bat

Here is the same script for reference:

@echo off
@REM # ===================================
@REM # daily_backup.bat
@REM # Copies work files to backup drive
@REM # Run every morning!
@REM # ===================================

@REM # --- Step 1: Set variables ---
SET SOURCE="C:\Users\Joshua\Work"
SET DEST="D:\Backup\Work"

@REM # --- Step 2: Do the backup ---
echo Starting backup...
xcopy %SOURCE% %DEST% /s /y

@REM # --- Step 3: Confirm ---
echo Backup complete!
PAUSE

Knowledge Check

1 / 4

What does REM stand for?

Up Next

Fc Command

Compare files and find differences instantly.