foreach-cli: Execute Command Per File

JSON →
library 1.8.1 ·javascript
verified May 27, 2026

foreach-cli is a command-line utility designed to execute a specified shell command for each file that matches a given glob pattern. Currently at version 1.8.1, the package provides a stable and reliable method for batch processing files. It differentiates itself from its predecessor, `each-cli`, by consistently setting the current working directory (CWD) to where `foreach-cli` was invoked, rather than changing it to the matched file's directory. This design choice simplifies command construction and prevents unexpected path issues. Additionally, it accepts command arguments as direct strings, enabling complex shell commands, including piping and redirects, that might be problematic with other tools. The utility supports various placeholders like `#{path}`, `#{dir}`, and `#{name}` to dynamically inject file-specific information into the executed commands.

total hits 12
actors 6 distinct systems
last hit 4d ago human
GPTBot
2
Script
2
Search engines
2
Humans
1

top countries 🇺🇸 United States · 🇫🇷 France · 🇨🇦 Canada · VN · 🇩🇪 Germany