Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

batch for loop with bracket in the command

I have a batch file with the following code:

for /f "tokens=*" %%a in ('dir /b /a-d') do (
 echo Processing %%a >>%LOG%
 dtsrun /S(local) /NNotesLoad /A"FilePath:8="%NOTESDIR%\%%a" /AClientID=%1 >>%LOG%

 echo Deleting %%a >>%LOG%
 del %%a /q
)

This is returning an error message of "/NNotesLoad was unexpected at this time" because the second bracket is effectively closing the FOR block.

I have to leave the (local) as the /S parameter.
How do I escape the brackets in the dtsrun line?

EDIT: Turns out you can specify the server in dtsrun for local as .

But I would still like an answer to the escaping for the brackets.

like image 264
benPearce Avatar asked Nov 18 '25 02:11

benPearce


1 Answers

The solution for escaping the brackets characters is to prefix with a caret ^

So it would read:

/S^(local^)
like image 111
benPearce Avatar answered Nov 20 '25 10:11

benPearce



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!