I had the zsh scriptprintf '%s\0' www/scripts6/lib/* | xargs -0 -I{} -P 50 babel {} > {}and it worked (i think.).  But I needed to actually copy the files to the scripts directory instead of scripts6.  Also, I needed to add an extra path to the list of paths manually, so I tried doing this:paths=$(printf '%s\0' www/scripts6/lib/* | sed -e 's@www/scripts6/@@g')paths=$paths'main.js'$'\0'echo -n $paths | xargs -0 -I {} -P 50 babel www/scripts6/{} > www/scripts/{}That was a BIG ACCOMPLISHMENT for me.  Anyway, the script makes the file named {} in the scripts directory (and nothing in the scripts/lib directory).  This leads me to believe that only the first {} in the code gets replaced by the argument, and not the second one (and I have no explanation for the absence of files in the scripts/lib directory).How can I make the script work as expected?
zsh capture and pipe output to another command
zsh;xargs
Redirection happens before xargs executes. so your first example also creates a file named {}, because xargs never got the chance to replace the last {}.Also, while you do try to separate the filenames by nulls to treat filenames correctly, the effort is in vain once you use echo. echo in zsh interprets the C-style escapes(\t, \n, etc) by default. You would need the -E option to disable that.Try this and see if it does what you wantsetopt monitorfor f in www/scripts6/lib/*(e*'REPLY=${REPLY#www/scripts6/}'*) main.js; do;  while (( $#jobstates >= 51 )); do     sleep 1  done  echo -E babel $f \> www/scripts/$f &doneIf the output seems ok, remove the echo -E and replace \> with >