{"id":13587055,"url":"https://github.com/marcusbuffett/pipe-rename","last_synced_at":"2025-04-09T04:04:45.067Z","repository":{"id":39888219,"uuid":"294565467","full_name":"marcusbuffett/pipe-rename","owner":"marcusbuffett","description":"Rename your files using your favorite text editor","archived":false,"fork":false,"pushed_at":"2024-04-28T23:30:40.000Z","size":293,"stargazers_count":385,"open_issues_count":9,"forks_count":14,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-05-01T13:08:24.398Z","etag":null,"topics":["command-line-tool","devtool","rust"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/pipe-rename","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcusbuffett.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-11T01:44:50.000Z","updated_at":"2024-06-11T04:54:18.664Z","dependencies_parsed_at":"2023-11-17T23:04:18.944Z","dependency_job_id":"4ede2844-eb34-45ef-b157-22f98f59a70d","html_url":"https://github.com/marcusbuffett/pipe-rename","commit_stats":{"total_commits":96,"total_committers":10,"mean_commits":9.6,"dds":0.6145833333333333,"last_synced_commit":"cc36e1124040ff0a2d9310b58da9ebe6b918e38c"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcusbuffett%2Fpipe-rename","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcusbuffett%2Fpipe-rename/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcusbuffett%2Fpipe-rename/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcusbuffett%2Fpipe-rename/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcusbuffett","download_url":"https://codeload.github.com/marcusbuffett/pipe-rename/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247974715,"owners_count":21026742,"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":["command-line-tool","devtool","rust"],"created_at":"2024-08-01T15:05:59.610Z","updated_at":"2025-04-09T04:04:45.041Z","avatar_url":"https://github.com/marcusbuffett.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# pipe-rename\n\n[![Crates.io](https://img.shields.io/crates/v/pipe-rename)](https://crates.io/crates/pipe-rename)\n\n`pipe-rename` takes a list of files as input, opens your `$EDITOR` of choice, then\nrenames those files accordingly.\n\n![](renamer.gif)\n\n## Installation\n\n`cargo install pipe-rename`\n\nThis will install the `renamer` binary.\n\n## Usage\n\nUsage is simple, just pipe a list of files into `renamer`. This will open your\n`$EDITOR` (or vim, if not set or passed with `--editor`) -- or `%EDITOR%` (or Notepad\non Windows, if not set or passed with `--editor`), and once your editor exits it\nwill detect which files were renamed:\n\n```bash\nls | renamer\n```\n\nYou can also supply filenames as positional arguments. To rename `.txt` files\nin the current directory:\n\n```bash\nrenamer *.txt\n```\n\nThe default behavior is to rename files, but you can override this. If you want\nto run `git mv old new` on each rename, you can do something like this:\n\n```bash\nls | renamer --rename-command \"git mv\"\n```\n\n## Help text\n\n```\nTakes a list of files and renames/moves them by piping them through an external editor\n\nUSAGE:\n    renamer [OPTIONS] [FILES]...\n\nARGS:\n    \u003cFILES\u003e...\n\n\nOPTIONS:\n    -c, --rename-command \u003cCOMMAND\u003e\n            Optionally set a custom rename command, like 'git mv'\n\n    -e, --editor \u003cEDITOR\u003e\n            Optionally set an editor, overriding EDITOR environment variable and default\n\n    -f, --force\n            Overwrite existing files\n\n    -h, --help\n            Print help information\n\n    -n, --filenames-only\n            Only rename filenames\n\n    -p, --pretty-diff\n            Prettify diffs\n\n    -u, --undo\n            Undo the previous renaming operation\n\n    -V, --version\n            Print version information\n\n    -y, --yes\n            Answer all prompts with yes\n```\n\n### Caveat emptor\n\n**NB:** it makes sense to be aware of the issues `ls` can cause in this\ncontext, depending on the `ls` flavor (or substitute, such as `lsd`, `exa`\n...) used. Please read [this document](https://web.archive.org/web/20230102124738/http://mywiki.wooledge.org/ParsingLs)\nfor more information.\n\nWhile your shell will pass the file names individually, no matter if they\ncontain whitespace, an `ls` that fails to detect the pipe and print one file\nname per line will cause issues. Unfortunately `ls -Q` also isn't a solution\nhere, because unlike the shell -- which will strip quotes prior to passing\nthem to invoked commands -- `renamer` won't handle the quoted names and will\nprobably complain about non-existent files, too.\n\n### Advanced usage\n\nIf you have tools like GNU `find` at your disposal, you can also use the\nfollowing method:\n\n```bash\nfind -type f -exec renamer {} +\n```\n\nThis would execute `renamer` with all of the files matched by `find`. You can\nuse additional `find` predicates such as `-name` or `-ipath` to limit which\nfiles to rename. There is, however, one caveat: on large lists of files you\nmay encounter multiple invocations of `renamer` -- and thus your editor -- due\nto how `find ... -exec {} +` works. It will pass as many file names on the\ncommand line as it can fit but it is limited by `ARG_MAX` (see `getconf ARG_MAX`\noutput for how long the overall command line length can be on your system).\n\nOther `find` flavors would allow the following, but it would invoke `renamer`\n-- and thus your editor -- *once for every single found file*:\n\n```bash\nfind -type f -exec renamer {} \\;\n```\n\nIn order to sidestep this issue, you can employ `xargs` in conjunction with\n`find` like so (`-print` is implied for `find`):\n\n```\nfind -type f | xargs renamer --editor vim\n```\n\nThe part past `xargs` is the invocation of `renamer` without the file names.\nIt exists just to demonstrate how you would pass arguments to `renamer` using\nthis method.\n\nIf your files contain wonky characters you could also try:\n\n```\nfind -type f -print0 | xargs -0 renamer --editor vim\n```\n\nAlas, this could be asking for trouble. If your file names contain line breaks,\nfor example, this could confuse `renamer` which expects a single file name per\nline when re-reading the edited file.\n\n### Known workarounds\n\n`renamer` will wait for the editor to close, before offering to rename the files according\nto your changes. Some editors cause issues with this method, because they spawn child\nprocesses or similar. This is a list of known workarounds for some editors. Feel free to\ncontribute by sending a pull request or opening an issue and giving the details.\n\nWe can work around these issues by explicitly using a method to invoke the desired editor,\nwhich works with the assumptions made by `renamer`. It can be done by passing `--editor`\n(short `-e`) or setting the environment `$EDITOR` (`%EDITOR%` with `cmd.exe` or\n`$env:EDITOR` with `pwsh.exe`).\n\n* Sublime Text can be used by passing `--editor \"subl -w\"` to have it wait until the files\n  are closed\n\n#### Windows-specific workarounds\n\n* VS Code can be used by passing `--editor \"code.cmd -\"` and then giving the other files\n* VSCodium analogously can be used with `--editor \"codium.cmd -\"`\n\n## Contributors ✨\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://mbuffett.com/\"\u003e\u003cimg src=\"https://avatars3.githubusercontent.com/u/1834328?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMarcus Buffett\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-marcusbuffett\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"https://github.com/marcusbuffett/pipe-rename/commits?author=marcusbuffett\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://git.ireas.org/\"\u003e\u003cimg src=\"https://avatars2.githubusercontent.com/u/165115?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eRobin Krahl\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-robinkrahl\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"https://github.com/marcusbuffett/pipe-rename/commits?author=robinkrahl\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"https://github.com/marcusbuffett/pipe-rename/issues?q=author%3Arobinkrahl\" title=\"Bug reports\"\u003e🐛\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://timkovi.ch/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/651077?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eMax Timkovich\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-mtimkovich\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"https://github.com/marcusbuffett/pipe-rename/commits?author=mtimkovich\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/bew\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/9730330?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eBenoit de Chezelles\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-bew\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e\u003c/td\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://assarbad.net/\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/3238620?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eOliver Schneider\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"#ideas-assarbad\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"https://github.com/marcusbuffett/pipe-rename/commits?author=assarbad\" title=\"Code\"\u003e💻\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcusbuffett%2Fpipe-rename","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcusbuffett%2Fpipe-rename","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcusbuffett%2Fpipe-rename/lists"}