
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
The move-file npm package is a utility for moving files and directories with ease. It supports various features such as overwriting existing files, renaming files, and ensuring the destination directory exists.
Basic File Move
This feature allows you to move a file from one location to another. The code sample demonstrates moving 'source.txt' to 'destination.txt'.
const moveFile = require('move-file');
(async () => {
await moveFile('source.txt', 'destination.txt');
console.log('The file has been moved');
})();
Overwrite Existing File
This feature allows you to move a file and overwrite the destination file if it already exists. The code sample demonstrates moving 'source.txt' to 'destination.txt' with the overwrite option enabled.
const moveFile = require('move-file');
(async () => {
await moveFile('source.txt', 'destination.txt', { overwrite: true });
console.log('The file has been moved and overwritten');
})();
Ensure Destination Directory Exists
This feature ensures that the destination directory exists before moving the file. If the directory does not exist, it will be created. The code sample demonstrates moving 'source.txt' to a nested directory structure.
const moveFile = require('move-file');
(async () => {
await moveFile('source.txt', 'non/existent/directory/destination.txt');
console.log('The file has been moved and the destination directory was created');
})();
fs-extra is a package that extends the native Node.js fs module with additional methods, including file moving capabilities. It provides a more comprehensive set of file system operations compared to move-file, such as copying, removing, and ensuring directories exist.
mv is a simple package for moving files and directories. It offers similar functionality to move-file but with a simpler API. It also supports overwriting existing files and ensuring the destination directory exists.
rename is a package focused on renaming files and directories. While it can be used to move files by renaming them to a new path, it lacks some of the additional features provided by move-file, such as ensuring the destination directory exists.
Move a file
The built-in fs.rename()
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.
$ npm install move-file
const moveFile = require('move-file');
(async () => {
await moveFile('source/unicorn.png', 'destination/unicorn.png');
console.log('The file has been moved');
})();
Returns a Promise
that resolves when the file has been moved.
Type: string
File you want to move.
Type: string
Where you want the file moved.
Type: Object
Type: boolean
Default: true
Overwrite existing destination file.
MIT © Sindre Sorhus
FAQs
Move a file - Even works across devices
The npm package move-file receives a total of 539,814 weekly downloads. As such, move-file popularity was classified as popular.
We found that move-file demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.