move-files

move files

Move Files License NPM version Dependency Status Build Status Coverage Status

Move files with emitter. Try to rename files first, and only if fail move them.

Install

npm i @cloudcmd/move-files

How to use?

const moveFiles = require('@cloudcmd/move-files');
const cwd = process.cwd();
const from = cwd + '/pipe-io';
const to = cwd + '/example';
const abortOnError = false;

const mv = moveFiles(from, to, [
    'LICENSE',
    'README.md',
    'package.json'
]);

mv.on('file', function(from, to) {
    console.log(`${from} -> ${to}`);
});

mv.on('directory', function(from, to) {
    console.log(`${from} -> ${to}`);
});

mv.on('progress', function(percent) {
    console.log(percent);
    
    if (percent >= 50) {
        mv.pause();
        mv.continue();
    }
});

mv.on('pause', () => {
    console.log('paused');
    mv.continue();
});

mv.on('error', (error) => {
    console.error(`${percent} -> ${name}: ${error.message}`);
    
    if (abortOnError)
        return mv.abort();
    
    mv.continue();
});

mv.on('end', function() {
    console.log('Moving ended up');
});

mv.pause();

Related

  • Remy - Remove files with emitter.
  • Jaguar - Pack and extract .tar.gz archives with emitter.
  • OneZip - Pack and extract zip archives with emitter.
  • Tar-to-zip - Convert tar and tar.gz archives to zip.

License

MIT

Related Repositories

trash

trash

Move files and folders to the trash ...

zotfile

zotfile

Zotero plugin to manage your attachments: automatically rename, move, and attach PDFs (or other files) to Zotero items, sync PDFs from your Zotero library to your (mobile) PDF reader (e.g. an iPad, Android tablet, etc.), and extract PDF annotations. ...

trash-cli

trash-cli

Move files and folders to the trash ...

CheatSheets

CheatSheets

Decided to move the gist into a repo of it's own so I can better link to the files ...

wallet-key-tool

wallet-key-tool

edit the contents of bitcoin wallet files (add/remove keys, import/export in different formats, move keys between different wallets) ...