FOR /F with multiple commands

Microsoft Windows
Post Reply
ace_dent
Posts: 1
Joined: 2023-Aug-09, 9:17 am
Location: UK
Contact:

FOR /F with multiple commands

Post by ace_dent »

Hi,
Is it possible to run multiple commands to evaluate within FOR /F?
e.g.
for /f tokens=* %%a in ('command1 | more') do echo %%a
OJBakker
Posts: 13
Joined: 2021-Jul-29, 7:06 am

Re: FOR /F with multiple commands

Post by OJBakker »

Yes, but you need to correct syntax errors to do this, especially escape the pipe symbol.

Code: Select all

for /f tokens^=* %%a in ('dir ^| more') do echo %%a
or

Code: Select all

for /f "tokens=*" %%a in ('dir ^| more') do echo %%a
Post Reply