Hi Tom,
Thanks for your answer, unfortunately I did try using the wildcarded
string TOY*.txt as the set and couldnt get it to use the wildcard it
just kept coming back with 'could not find TOY*.txt'. This was with
all types of quote and usebackq. I'm sure I was doing something wrong
but couldnt seem to work out what.
The undefined vars coming back as literal echos is not unexpected, I
just wanted to have more echos than tokens so I could see what was
being initialised and what wasnt. My intention (as alluded to) was to
manipulate a pipe delimited file (to change the field order more
specifically)
The solution in the end was to use a second, nested for loop to
process each line of the 'dir' command output which seems to have done
the trick. Please see below
@echo off
:top
c:
cd c:\nl\input
for /f "delims=" %%a in ('dir /b /a-d TOY*.txt') do (
for /f "tokens=1-17 delims=|" %%b in ('type "%%a"') do (
@echo %%b^|Toy Co^|%%f^|^|^|%%g^|%%i^|COUNTY^|%%d^|%%e > c:\nl\output\%
%a
@echo %%b^|Toy Co^|%%f^|^|^|%%g^|%%i^|COUNTY^|%%d^|%%e
del %%a
)
)
c:\nl\sleep 1
GOTO top