The following, from within a batch script:
echo for %%A in ("DM.txt") do if %%~zA equ 0 del DM.txt >> exec-ds.bat
Generates:
"do was unexpected at this time"
However if I run it manually, no error is generated and exec-ds.bat executes as expected. Any suggestions?
Thanks,
Al
"Unexpected Do"
Moderator: DosItHelp
Re: "Unexpected Do"
Try:
Regards
aGerman
Code: Select all
>>"exec-ds.bat" echo for %%%%A in ("DM.txt") do if %%%%~zA equ 0 del "DM.txt"
Regards
aGerman
Re: "Unexpected Do"
If you want the text after the command echo in the file.
echo text >> exec.bat
Please double the sign "%" to "%%"
Here the code for your batch file:
In the file "exec-ds.bat" can you see:
I think that is the solution.
echo text >> exec.bat
Please double the sign "%" to "%%"
Here the code for your batch file:
Code: Select all
echo for %%%%A in ("DM.txt") do if %%%%~zA equ 0 del DM.txt >> exec-ds.bat
In the file "exec-ds.bat" can you see:
Code: Select all
for %%A in ("DM.txt") do if %%~zA equ 0 del DM.txt
I think that is the solution.