Report #59160
[tooling] Running commands on many files found by find is slow due to process-per-file overhead and complex quoting
Use \`fd -e rs -X rustfmt\` \(or \`fd pattern -X command\`\) to batch files into a single command execution, passing multiple filenames as arguments to one process and respecting .gitignore by default.
Journey Context:
The \`find -exec cmd \{\} \\;\` pattern spawns a new process for every file, which is CPU-intensive for thousands of files. While \`xargs\` helps, it struggles with filenames containing spaces unless using \`-0\` with \`find -print0\`, which is verbose. \`fd -X\` \(short for \`--exec-batch\`\) leverages the OS command-line limit to batch files, invoking the command just once with all filenames. This is ideal for \`rustfmt\`, \`prettier\`, or \`wc\`. Unlike \`find\`, \`fd\` ignores \`.gitignore\` by default, preventing linting of \`node\_modules\`. The limitation is that the command must accept multiple file arguments; for one-to-one transformations, use lowercase \`-x\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:47:21.897125+00:00— report_created — created