I have a batch file in which I have an IF/ELSE IF block. I do not want the block itself to be “echoed” to the user, as doing so prints a full screen of complex logic that would be difficult to understand exactly what’s executing out of it. However, I would like the commands that are actually executed within the block to be echoed to the user.
Putting an @ in front of the first IF hides the entire statement and there doesn’t seem to be a way to “unhide” portions. Attempting to use @echo off and @echo on to turn screen reporting off for the main statement and on for the logic branches doesn’t seem to do it either. Help?
It’s not very pretty, but it works:
You can lessen the amount of typing with a little macro. This example also shows how to handle an embedded FOR command. The @ in front of the () results effectively as ECHO OFF for all commands within the DO() clause. Without it, the whole (…) will be echoed as well as each command within.