I have the below code snippet which outputs a variable in to a text file.
%drone% will be a simple text string, and the %counter% is a number which is in a loop to count the iterations.
The echo %drone% !counter! echos the correct values to the screen but in the echo Done: %drone% Files deleted: !tempcounter! >> clearTempFilesonDrones.txt code the !tempcounter! variable is blank when outputted to the file.
I've tried to set it to a temp variable and use %tempvariable%, but that didn't work. I also tried like "!counter!" incase it would think that that's a string instead of just a number, but didn't work either.
echo %drone% %counter%
endlocal
echo Done: %drone% Files deleted: !counter! >> clearTempFilesonDrones.txt
Any ideas?
I can't copy the entire code onto a pastebin or the like as blocked in current client, so just uploaded an extract.