{"id":13454434,"url":"https://github.com/sindresorhus/move-file","last_synced_at":"2025-10-19T03:24:58.230Z","repository":{"id":49589801,"uuid":"109383955","full_name":"sindresorhus/move-file","owner":"sindresorhus","description":"Move a file - Even works across devices","archived":false,"fork":false,"pushed_at":"2023-11-05T07:53:24.000Z","size":25,"stargazers_count":199,"open_issues_count":0,"forks_count":15,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-05-03T07:27:14.466Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2017-11-03T10:40:00.000Z","updated_at":"2025-04-11T17:08:49.000Z","dependencies_parsed_at":"2023-09-27T10:37:36.855Z","dependency_job_id":"ae6ee8f6-0818-4632-8b0e-aa058f45e490","html_url":"https://github.com/sindresorhus/move-file","commit_stats":{"total_commits":26,"total_committers":5,"mean_commits":5.2,"dds":"0.23076923076923073","last_synced_commit":"3b538f1778f5f8aec4fbcee50c3443c2c1e1f552"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmove-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmove-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmove-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fmove-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/move-file/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253666434,"owners_count":21944675,"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-07-31T08:00:54.039Z","updated_at":"2025-10-19T03:24:58.178Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","Repository","JavaScript","包","目录","Filesystem","Uncategorized"],"sub_categories":["Filesystem","文件系统","Uncategorized"],"readme":"# move-file\n\n\u003e Move a file\n\nThe built-in [`fs.rename()`](https://nodejs.org/api/fs.html#fs_fs_rename_oldpath_newpath_callback) is just a JavaScript wrapper for the C `rename(2)` function, which doesn't support moving files across partitions or devices. This module is what you would have expected `fs.rename()` to be.\n\n## Highlights\n\n- Promise API.\n- Supports moving a file across partitions and devices.\n- Optionally prevent overwriting an existing file.\n- Creates non-existent destination directories for you.\n\n## Install\n\n```sh\nnpm install move-file\n```\n\n## Usage\n\n```js\nimport {moveFile} from 'move-file';\n\nawait moveFile('source/unicorn.png', 'destination/unicorn.png');\nconsole.log('The file has been moved');\n```\n\n## API\n\n### moveFile(sourcePath, destinationPath, options?)\n\nReturns a `Promise` that resolves when the file has been moved.\n\n### moveFileSync(sourcePath, destinationPath, options?)\n\n#### sourcePath\n\nType: `string`\n\nThe file you want to move.\n\n#### destinationPath\n\nType: `string`\n\nWhere you want the file moved.\n\n#### options\n\nType: `object`\n\nSee [Options](#options-2).\n\n### renameFile(source, destination, options?)\n\nReturns a `Promise` that resolves when the file has been renamed. `source` and `destination` must be in the same directory.\n\n### renameFileSync(source, destination, options?)\n\n#### source\n\nType: `string`\n\nThe file you want to rename.\n\n#### destination\n\nType: `string`\n\nWhat you want to rename the file to.\n\n#### options\n\nType: `object`\n\nSee [Options](#options-2).\n\n### Options\n\n##### overwrite\n\nType: `boolean`\\\nDefault: `true`\n\nOverwrite existing destination file.\n\n##### cwd\n\nType: `string`\\\nDefault: `process.cwd()`\n\nThe working directory to find source files.\n\nThe source and destination path are relative to this.\n\n##### directoryMode\n\nType: `number`\\\nDefault: `0o777`\n\n[Permissions](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) for created directories.\n\nIt has no effect on Windows.\n\n## Related\n\n- [move-file-cli](https://github.com/sindresorhus/move-file-cli) - CLI for this module\n- [copy-file](https://github.com/sindresorhus/copy-file) - Copy a file\n- [cpy](https://github.com/sindresorhus/cpy) - Copy files\n- [make-dir](https://github.com/sindresorhus/make-dir) - Make a directory and its parents if needed\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fmove-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fmove-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fmove-file/lists"}