Skip navigation

JSI Tip 8097. Enclosing a set of commands in parenthesis () simplifies some batch files?

Enclosing a set of commands in parenthesis () groups them together.

Example:

If your batch contains a set of commands like:
@echo First line of new file>"%TEMP%\FileName.tmp"
CD C:\FolderName
@echo Folder is %CD%>>"%TEMP%\FileName.tmp"
dir /b>>"%TEMP%\FileName.tmp"

Then, using parenthesis results in a simpler construct:

(
 @echo First line of new file
 cd C:\FolderName
 @echo Folder is %CD%
 dir /b
) >"%TEMP%\FileName.tmp"



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish