Limiting the scope of glob qualifiers in zsh
You don't need a loop. An intermediate variable is enough. Use the ^
parameter expansion sigil to distribute over the array.
dirpath=(*(N-/))
print -rC1 -- $^dirpath/*(.NOL[1,2])
Or you can use an anonymous function to avoid the temporary variable (which becomes $argv
/$@
the anonymous function arguments):
() {print -rC1 -- $^@/*(.NOL[1,2])} *(N-/)