{"id":15639976,"url":"https://github.com/danielgtaylor/ladon","last_synced_at":"2025-04-14T16:16:41.124Z","repository":{"id":14088899,"uuid":"16792781","full_name":"danielgtaylor/ladon","owner":"danielgtaylor","description":"A small, simple cross-platform utility to process many files in parallel.","archived":false,"fork":false,"pushed_at":"2019-09-19T11:06:47.000Z","size":242,"stargazers_count":82,"open_issues_count":10,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-14T16:16:22.885Z","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/danielgtaylor.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":"2014-02-13T05:21:11.000Z","updated_at":"2024-03-31T10:58:14.000Z","dependencies_parsed_at":"2022-08-31T07:40:33.438Z","dependency_job_id":null,"html_url":"https://github.com/danielgtaylor/ladon","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgtaylor%2Fladon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgtaylor%2Fladon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgtaylor%2Fladon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielgtaylor%2Fladon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielgtaylor","download_url":"https://codeload.github.com/danielgtaylor/ladon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248914117,"owners_count":21182359,"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":"2024-10-03T11:29:20.190Z","updated_at":"2025-04-14T16:16:41.096Z","avatar_url":"https://github.com/danielgtaylor.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Ladon\n=====\n\n[![Dependency Status](http://img.shields.io/david/danielgtaylor/ladon.svg?style=flat)](https://david-dm.org/danielgtaylor/ladon) [![Build Status](http://img.shields.io/travis/danielgtaylor/ladon.svg?style=flat)](https://travis-ci.org/danielgtaylor/ladon) [![NPM version](http://img.shields.io/npm/v/ladon.svg?style=flat)](https://www.npmjs.org/package/ladon) [![NPM license](http://img.shields.io/npm/l/ladon.svg?style=flat)](https://www.npmjs.org/package/ladon)\n\nA small, simple utility to process many files in parallel. It is meant for people comfortable with using a terminal but strives to be as easy to use as humanly possible.\n\nLadon is named after the multiheaded serpent dragon from Greek mythology, slain by Heracles and thrust into the sky as the constellation Draco. His many heads allow you to efficiently work on many files at once.\n\nFeatures\n--------\n* Supports Windows, Mac OS X, Linux, etc\n* Select files via a simple [glob](https://www.npmjs.org/package/glob)\n* Autodetects system CPU count\n* Configurable parallel process count\n* Simple command template syntax\n* Built-in templated `mkdir -p` support\n\nInstallation\n------------\nThe only dependency is [Node.js](http://nodejs.org/). Standard global installation via NPM applies:\n\n```bash\nsudo npm install -g ladon\n```\n\nExamples\n--------\nThe following are some examples of what is possible:\n\n```bash\n# Print all text file names relative to the current directory\nladon \"**/*.txt\" -- echo RELPATH\n\n# Calculate SHA1 sums of all your PDFs and save them in a file\nladon \"~/Documents/**/*.pdf\" -- shasum FULLPATH \u003ehashes.txt\n\n# Generate thumbnails with ImageMagick and keep directory structure\nladon -m thumbs/RELDIR \"**/*.jpg\" -- convert FULLPATH -thumbnail 100x100^ -gravity center -extent 100x100 thumbs/RELPATH\n```\n\nYou can also replace common `bash`-isms with true parallel processing:\n\n```bash\n# Typical bash for loop\nfor f in ~/Music/*.wav; do lame -V 2 $f ${f%.*}.mp3; done\n\n# Parallelized via ladon to use all CPUs\nladon \"~/Music/*.wav\" -- lame -V 2 FULLPATH DIRNAME/BASENAME.mp3\n```\n\nTutorial\n--------\nThe following is a brief walkthrough of how to use `ladon`.\n\n### Command Structure\nThe basic command structure consists of two parts that are split by `--`. The first part consists of the `ladon` command and its options, while the second consists of the command you want to run in parallel. The only required `ladon` option is a file selector glob.\n\n```bash\nladon [options] glob -- command\n```\n\nLadon works by selecting files via a glob, which supports wildcards like `*` and `**` to match any file or any directory recursively. For example, `*.txt` would select all the text files in the current directory, while `**/*.txt` would select all the text files in the current directory __and__ any child directories. [Read the full glob syntax](https://www.npmjs.org/package/glob).\n\nThe second half of the command structure is the command you wish to run in parallel over the selected files. It can be anything you want and can use special variables (documented below).\n\n### Using Variables\nA full variable reference can be found below. The most common use case is to get the full path to a file that you wish to process, and this can be done via the `FULLPATH` variable. For example, to print out the full path to each file that is selected by your glob:\n\n```bash\nladon \"*\" -- echo FULLPATH\n```\n\nYou can also safely mix variables with normal text to construct new paths:\n\n```bash\nladon \"*\" -- echo RELDIR/BASENAME.zip\n```\n\n### Making Directories\nMany commands will generate a new file. Sometimes you want to overwrite existing files, but other times you'd rather create a copy. Ladon has built-in support for a templated `mkdir -p` feature which will recursively ensure directories exist before running your command on a selected file. The `RELDIR` variable is very useful here. This is perhaps best illustrated via example:\n\n```bash\n# Recursively copy all files and keep directory structure\nladon -m foo/RELDIR \"myfiles/**/*\" -- cp FULLPATH foo/RELPATH\n```\n\nIn the example above every file and directory in the `myfiles` directory will be copied over to the new directory `foo`. If there is a `myfiles/docs/test.txt` then there will be a `foo/docs/test.txt` file created.\n\nVariable Reference\n------------------\nThe following variables can be used in both the command and the directory name when using the `--makedirs` option. The examples below assume that the _current working directory_ is `/home/dan/`.\n\n| __Variable__ | __Description__                               | __Example__               |\n| ------------ | --------------------------------------------- | ------------------------- |\n| FULLPATH     | Full path, equivalent to DIRNAME/BASENAME.EXT | `/home/dan/books/foo.txt` |\n| DIRNAME      | Directory name                                | `/home/dan/books`         |\n| BASENAME     | File name without extension                   | `foo`                     |\n| EXT          | File name extension                           | `txt`                     |\n| RELDIR       | Relative directory name                       | `books`                   |\n| RELPATH      | Relative file path                            | `books/foo.txt`           |\n\nUse as a Library\n----------------\nYou can also use ladon as a basic library in Node.js.\n\n```bash\nnpm install ladon\n```\n\nThen, just `require` and use it:\n\n```javascript\nvar ladon = require('ladon');\n\n// The command parser (based on yargs)\nvar args = ladon.parser.parse(['ladon', '**/*.txt', '--', 'echo', 'FULLPATH']);\n\n// Run the command\nladon.run(args, function (err) {\n    if (err) console.error(err.toString());\n});\n```\n\nAlternatives\n------------\n\n* [xargs](http://offbytwo.com/2011/06/26/things-you-didnt-know-about-xargs.html)\n* [GNU Parallel](http://www.gnu.org/software/parallel/)\n\nLicense\n-------\nSee http://dgt.mit-license.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgtaylor%2Fladon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielgtaylor%2Fladon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielgtaylor%2Fladon/lists"}