{"id":23790086,"url":"https://github.com/hash-bang/cli-foreachfile","last_synced_at":"2025-09-06T08:31:21.928Z","repository":{"id":29128013,"uuid":"32657857","full_name":"hash-bang/cli-foreachfile","owner":"hash-bang","description":"Simple CLI utility to recursively execute a command for each matching file","archived":false,"fork":false,"pushed_at":"2020-05-14T03:55:39.000Z","size":30,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-25T16:02:48.708Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hash-bang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-22T01:53:09.000Z","updated_at":"2020-09-22T00:37:38.000Z","dependencies_parsed_at":"2022-09-05T13:00:47.528Z","dependency_job_id":null,"html_url":"https://github.com/hash-bang/cli-foreachfile","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hash-bang%2Fcli-foreachfile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hash-bang%2Fcli-foreachfile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hash-bang%2Fcli-foreachfile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hash-bang%2Fcli-foreachfile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hash-bang","download_url":"https://codeload.github.com/hash-bang/cli-foreachfile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232104782,"owners_count":18473200,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-01-01T17:18:21.175Z","updated_at":"2025-01-01T17:18:21.728Z","avatar_url":"https://github.com/hash-bang.png","language":"JavaScript","readme":"ForEachFile\n===========\nSimple CLI utility to recursively execute a command for each matching file.\n\nExamples:\n\n```\n# Visit each .tar file (setting the directory to its location) and untar:\n\u003e each '**/*.tar' -- tar xvf %f\n\n# Convert all .jpg images to .png\n\u003e each '**/*.jpg' -- convert %b.jpg %b.png\n```\n\nUsage\n-----\n```\nUsage: each [glob] -- \u003ccommand\u003e\n\nOptions:\n  -V, --version            output the version number\n  -c, --command \u003cstring\u003e   Explicitally specify the command to run\n  -d, --dir                Change into each files directory before executing\n  -n, --dry-run            Do not run anything, instead show what would be run\n                           -implies `-v`\n  -g, --glob \u003cexpr\u003e        Explicitally specify the glob to use\n  -l, --log \u003cexpr\u003e         Log text before each execution (default:\n                           \"${colors.blue('[File]')} %r\")\n  -p, --parallel \u003cnumber\u003e  Specify the number of processes to run in parallel\n                           (default: 1)\n  -v, --verbose            Be verbose\n  -h, --help               output usage information\n\nNotes:\n  * Command arguments and log output can use ES6 templates or simple percentage prefix characters\n\nExamples:\n\n  # List all basenames from this directory recursively\n  each '**/*' -- echo %f\n\n  # Convert all JPG images into PNG\n  each '**/*.jpg' -- convert %b.jpg %b.png\n```\n\n\nInstallation\n------------\nInstall globally with NPM:\n\n```\nsudo npm install -g cli-foreachfile\n```\n\n\nCommand expansion\n-----------------\nCommands can be written in a variety of ways. Each of the below tokens gets expanded into the value shown.\n\n| Category       | Token           | Example                    | Description                      |\n|----------------|-----------------|----------------------------|----------------------------------|\n| File           | `%b`            | `myfile.foo`               | File name                        |\n| \"              | `%f`            | `myfile.foo`               | File name                        |\n| \"              | `{{name}}`      | `myfile.foo`               | File name without extension      |\n| \"              | `{{base}}`      | `myfile`                   | File name                        |\n| \"              | `{{basename}}`  | `myfile`                   | File name                        |\n| \"              | `{{relative}}`  | `./myfile.foo`,            | File name relative to PWD        |\n| \"              | `%r`            | `./myfile.foo`,            | File name relative to PWD        |\n| File Info      | `%e`            | `foo`                      | File extension                   |\n| \"              | `{{ext}}`       | `foo`                      | File extension                   |\n| Directory      | `%d`            | `/foo/bar/baz/myfile.foo`  | Relative dir to pwd              |\n| \"              | `{{dir}}`       | `/foo/bar/baz`             | The dir portion of the full path |\n| \"              | `{{dirname}}`   | `/foo/bar/baz`             | The dir portion of the full path |\n| Full Path      | `%p`            | `/foo/bar/baz/myfile.foo`  | Full File path                   |\n| \"              | `{{path}}`      | `/foo/bar/baz/myfile.foo`  | Full File path                   |\n| Utilities      | `{{colors}}`    |                            | [Chalk](https://github.com/chalk/chalk) Instance |\n|                | `{{path}}`      |                            | [Path](https://nodejs.org/api/path.html) NodeJS Core Instance |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhash-bang%2Fcli-foreachfile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhash-bang%2Fcli-foreachfile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhash-bang%2Fcli-foreachfile/lists"}