Cynosure.X International LLC


Add Comment | Related Links | TrackBack
Related Content

Multi-Line Comments in Batch File

The DOS/Windows batch language may not be as powerful as UNIX shell scripting language, but you can still get a lot of things done with it. The batch language only supports single line comments with the "rem" keywoard, which stands for remark. So to comment out the following example, you'd have to put the "rem" keywoard in front of every line:

rem if exist "%distroFile%" (
rem copy "%distroFile%" "%tmpDir%"
rem ) else (
rem echo *** %distroFile% does not exist!
rem )

Well, that's a lot of work. As you can see in the example above, that's five line and a lot of typing. And you'd have to change the cursor position for every line. Don't you wish there is a C or Java-like multi-line comment (/* */) sequence?

Well, you can comment out multi-line statements by surrounding them with a goto and a label. The same example above would be changed to the following:

goto :comment1
if exist "%distroFile%" (
copy "%distroFile%" "%tmpDir%"
) else (
echo *** %distroFile% does not exist!

The goto statement will skip all of the statement below until it gets to the ":comment1" label. You'll just have to use a different label for each comment clause. Now, isn't that easier?

Chieh Cheng
Tue, 29 Jul 2008 22:21:24 +0000

Add Comment | Related Links | TrackBack
Related Content

Did your message disappear? Read the Forums FAQ.

Add Comment

Spam Control | * indicates required field
Your Name: *
Remember Me!
Comment: *
File attachment is optional. Please do not attach a file to your submission unless it is relevent.
Attach File:
(20 MB Max)
Spam Protection: * Answer of 6 + 4?
Click button only once, please!


TrackBack only accepted from WebSite-X Suite web sites. Do not submit TrackBacks from other sites.

Send Ping | TrackBack URL | Spam Control

No TrackBacks yet. TrackBack can be used to link this thread to your weblog, or link your weblog to this thread. In addition, TrackBack can be used as a form of remote commenting. Rather than posting the comment directly on this thread, you can posts it on your own weblog. Then have your weblog sends a TrackBack ping to the TrackBack URL, so that your post would show up here.

Messages, files, and images copyright by respective owners.

Products | Services
Forums | Latest | RSS
Library | Search | Wiki
Help | Licenses

Login | Register

50 Users Online

Hacking Digital Cameras
Fun for Photographers

Amazon Associate

Copyright © 1996 - 2024. All Rights Reserved.