How to Comment with REM
Add notes to your scripts that the computer ignores — but you'll thank yourself later.
Start Interactive LessonHow 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.
Step 1: REM in the Terminal
Type a REM line in CMD and watch what happens:
Notice: When you run
REMdirectly in the terminal, the line is shown — it just doesn't do anything. In a.batscript, 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.
Tip: Be careful about wrapping variables in quotes inside REM lines — you can accidentally double-quote things if you're not careful.
@REMis the recommended style in scripts.
Step 3: The :: Shorthand
Many batch pros use :: as a faster-to-type comment marker:
⚠️ Warning:
::can cause errors insideFORloops orIFblocks. 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.
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 / 4What does REM stand for?