flatten-this-folder
v0.1.0
Published
Flatten the folder by moving all files to current directory
Downloads
24
Readme
Flatten This Folder
flatten
is a CLI (command-line interface) that will flatten your folder structure in whatever folder you run it in. All the files in all the sub-folders will be moved to the current directory. No folders are deleted or moved.
If a filename collision happens, the CLI will append the filename with a dash and a number (e.g. -1
, -2
, ... -69
). If any error happens, it will be logged and the corresponding file will not be moved.
Install
npm install -g flatten-this-folder
Use
In your terminal run flatten
, this will flatten the current folder .
Running flatten abc
will flatten the folder abc
inside the current working directory in your terminal.
Catastrophe prevention
Any time there are more than 10 files being moved, the CLI will notify you of the total number and will require you type in "yes" before it will move files.
⚠ WARNING ⚠ - running flatten
in any system directory (and then typing in "yes" for the CLI to do its work) is dangerous since there is no "undo" after files move (can break your computer).
Developing
Edit the move.js
file and run npm start
to see your script working
npm start
will run the command against the playground foldernpm run test
will test that the renamed file list matches the expected outcomenpm run reset
will reset the playground folder to its original formnpm run check
will perform the above three tasks one after another:- flatten the playground folder
- run the test
- reset the playground folder to its initial state
npm run global
will install theflatten
CLI / terminal command for you to use
Todo
- [ ] if argv[2]
.startsWith('.')
filter for the file (e.g.flatten .mp4
only moves .mp4 files) - [ ] if argv[2]
.equals('dry')
only console log everything - [ ] unit test to check file contents too