Reputation: 4028
ALl,
I like my indentation and new lines to make my code readable however for some reason it is breaking my batch script.
This works for example:
cd %inbox%
for /r %%x in (*.txt) do echo "%%x"
However if I try and move the action part of the loop to a new line, the command terminal opens and closes.
cd %inbox%
for /r %%x in (*.txt)
do echo "%%x"
I am new to batch scripting so from what I can tell here it seems that it is sensitive to whitespace/ EOL
How can I format this code without breaking it?
Upvotes: 0
Views: 1025
Reputation: 82327
For formatting you could use code blocks, but it's important that the block begins on the same line like the do
for /r %%x in (*.txt) do (
echo %%x
echo ---
)
Upvotes: 4
Reputation: 63502
That happens because for
is a command, and it ends where the line ends. One option would be to add a ^
where you want to split the command, so that the interpreter knows to stitch the current line with the one below before executing the command.
cd %inbox%
for /r %%x in (*.txt) ^
do echo "%%x"
Upvotes: 3