xiaoyunwu
asked on
Batch For loop
I am trying to do a simple batch FOR loop, but I can't figure out how to use a | in the command.
For instance,
FOR /F %G IN ('dir /b') DO echo %G works
however
FOR /F %G IN ('dir /b | findstr /v xml') DO echo %G doesn't not work
(| was unexpected at this time.)
I need to do a directory listing but exclude at least one specific file from this loop. If I run: (dir /b | findstr /v xml) then I get the desired list of files; however, I can't figure out how to use it in the FOR loop
For instance,
FOR /F %G IN ('dir /b') DO echo %G works
however
FOR /F %G IN ('dir /b | findstr /v xml') DO echo %G doesn't not work
(| was unexpected at this time.)
I need to do a directory listing but exclude at least one specific file from this loop. If I run: (dir /b | findstr /v xml) then I get the desired list of files; however, I can't figure out how to use it in the FOR loop
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.