A recent question contains a problem that I many times used to think about but still do not know if it has an elegant solution:
Suppose, I have a command that forms a list of filenames or directories: dir /B /AD. Then, I would like to pipe the result of the command to an iterator that would do something with each filename.
How can I do it?
Instead of piping, one can certainly use backtick version of the for:
for /F "usebackq" %F in (`dir /B /AD`) do @echo %F
But I am interested here in getting the data from stdin, so that I would not hardcode the source of the filenames.
I happen to have found a solution myself:
This is even better than I thought, because it allows filtering directly in backticks expression. For example to exclude some particular filenames (.svn and _lib) I can write: