@hutsoninc/flatten-dir
v1.0.3
Published
Recursively flatten a directory
Downloads
745
Readme
flatten-dir
Recursively flatten a directory (moves all files from subfolders into the one folder).
Usage
npm install @hutsoninc/flatten-dir
const flatten = require('@hutsoninc/flatten-dir');
await flatten('path-to-directory', {
// options
});
Options
rename
Type: Function
Used to rename a file when the file name is already taken.
Default:
basename => {
if (/-\d$/.test(basename)) {
let arr = basename.split('-');
arr[arr.length - 1] = Number(arr[arr.length - 1]) + 1;
return arr.join('-');
}
return `${basename}-1`;
}
Related
- flatten-dir-cli - CLI for this module
License
MIT © Hutson Inc