8097 » Enclosing a set of commands in parenthesis () simplifies some batch files? 01-Jun-04
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"
End of Article

