{"id":29275888,"url":"https://github.com/peterroe/renames","last_synced_at":"2025-07-05T07:11:29.209Z","repository":{"id":46235307,"uuid":"514874895","full_name":"peterroe/renames","owner":"peterroe","description":"A good helper for batch renaming files.","archived":false,"fork":false,"pushed_at":"2022-07-20T15:58:16.000Z","size":102,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-03-04T01:14:01.549Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/peterroe.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":"2022-07-17T15:01:34.000Z","updated_at":"2022-07-20T16:00:19.000Z","dependencies_parsed_at":"2022-08-25T10:30:53.805Z","dependency_job_id":null,"html_url":"https://github.com/peterroe/renames","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/peterroe/renames","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterroe%2Frenames","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterroe%2Frenames/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterroe%2Frenames/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterroe%2Frenames/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peterroe","download_url":"https://codeload.github.com/peterroe/renames/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterroe%2Frenames/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263699784,"owners_count":23497963,"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-07-05T07:11:24.522Z","updated_at":"2025-07-05T07:11:29.204Z","avatar_url":"https://github.com/peterroe.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![img](./logo.svg)\n\n## renames\n\nA good helper for batch renaming files.\n\n## Install\n\n```sh\n$ npm i -g renames\n```\n\n## Usage \n\n```shell\n$ renames \u003cbeforePatten\u003e \u003cafterPatten\u003e --dir \u003cdir\u003e          # preview\n$ renames \u003cbeforePatten\u003e \u003cafterPatten\u003e --dir \u003cdir\u003e  --write # write to disk\n```\n\n**example 1:**\n\nSuppose you now have the following directory structure:\n\n```shell\n├─ components\n│  ├─ ListPost.tsx\n│  ├─ NavBar.tsx\n│  ├─ ToggleTheme.tsx\n```\n\nJust run `renames` and it will rename all files in the directory to match the new file name.\n\n\n```shell\nrenames \"([A-Z])([a-z]*)([A-Z])([a-z]*).tsx\" \"([a-z])([a-z]*)-([a-z])([a-z]*).tsx\" --dir ./components --write\n```\n\n```shell\n├─ components\n│  ├─ list-post.tsx\n│  ├─ nav-bar.tsx\n│  ├─ toggle-theme.tsx\n```\n\n**example 2:**\n\n```shell\n├─ tests\n│  ├─ sort_test.js\n│  ├─ match_test.js\n│  ├─ index_test.js\n```\n\n```shell\nrenames \"([a-z]*)_([a-z]*).js\" \"([a-z]*).([a-z]*).ts\" --dir ./tests --write\n```\n\n```shell\n├─ tests\n│  ├─ sort.test.ts\n│  ├─ match.test.ts\n│  ├─ index.test.ts\n```\n\n**example 3:**\n\n```shell\n├─ src\n│  ├─ qBar.js\n│  ├─ BFoo.js\n│  ├─ zBaz.js\n```\n\n```shell\n'([qB]+)([A-Z])([a-z]*).js' '()([A-Z])([a-z]*).js' --dir src --write\n```\n\n```shell\n├─ src\n│  ├─ ar.js\n│  ├─ Foo.js\n│  ├─ zBaz.js\n```\n\n## Base patten rule\n\n| patten | description |\n| -- | -- | \n| `()` | match an expression |\n| `[a-z]` | match a lowercase letter |\n| `[A-Z]` | match an uppercase letter |\n| `*` | match any number of characters |\n| `?` | match zero or one character |\n| `+` | match one or more characters |\n\n## Notice\n\nIn the `\u003cbeforePatten\u003e` and  `\u003cafterPatten\u003e`, the number of `()` must be equal.\n\nSuch as if you want:\n\n```shell \n├─ src\n│  ├─ sLog.ts\n│  ├─ qWitch.ts\n│  ├─ Index.ts\n│  ├─ App.ts\n```\n\nTransform to:\n\n```shell\n├─ src\n│  ├─ Log.ts\n│  ├─ Witch.ts\n│  ├─ Index.ts\n│  ├─ App.ts\n```\n\nYou should run:\n\n```diff\n- renames '([a-z]?)([A-Z])([a-z]*).js' '([A-Z])([a-z]*).js --dir ./src --write    // ❌\n+ renames '([a-z]?)([A-Z])([a-z]*).js' '()([A-Z])([a-z]*).js' --dir ./src --write // ✅\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterroe%2Frenames","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterroe%2Frenames","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterroe%2Frenames/lists"}