Link to home
Start Free TrialLog in
Avatar of xiaoyunwu
xiaoyunwuFlag for United States of America

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
ASKER CERTIFIED SOLUTION
Avatar of Lee W, MVP
Lee W, MVP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial