Help you manage an ordered list of filenames, by splicing it.
npm i new-order -g
In the directory where you need to work :
new-order --move fileToMove --before otherFile
new-order --move fileToMove --after otherFile
fileToMove and otherFile can be directories.
Currently no relative or absolute file paths supported, just plain filenames.
Let's say you want to write a book about rainbows to cheer you up during a sad Blue Monday. Each chapter will be about a specific color and will have its own markdown file.
Here's the initial content of your book directory, files are for now sorted alphabetically :
Your story is a journey along the light spectrum, from infrared to ultraviolet.
So you need to reorder your chapters. Doing it by hand (with the
mv command for example), you'll get :
...1 red.md2 green.md3 blue.md
Now you need to write the orange chapter. It should fit in 2nd position, between red and green. But if you simply call it 2 orange.md it won't work. You need to rename all the files coming after :
....1 red.md2 orange.md3 green.md4 blue.md
As you've guessed, this task can be very tedious and error-prone for large amounts of files.
Let's see how can
new-order help you doing this chore. 'Time to write down yellow.md, your next episode following the newly created orange's one.
...1 red.md2 orange.md3 green.md4 blue.mdyellow.md
You can handle this in several ways with the same result :
new-order --move yellow.md --after 2\ orange.md
new-order --move yellow.md --before 3\ green.md
...1 red.md2 orange.md3 yellow.md4 green.md5 blue.md
What happens if you have more than 9 files?
...1 red.md2 orange.md3 yellow.md4 lime.md5 green.md6 cyan7 blue.md8 indigo.md9 violet.mdjade.md
new-order --move jade.md --after 5\ green.md
...01 red.md02 orange.md03 yellow.md04 lime.md05 green.md06 jade.md07 cyan08 blue.md09 indigo.md10 violet.md
new-order will automatically adjust to a 2 digits naming scheme.