75lb / renamer

Rename files in bulk.
MIT License
526 stars 30 forks source link

Ability to specify an order for renaming files #31

Closed tibuurcio closed 6 years ago

tibuurcio commented 6 years ago

Hi there! Thanks for this awesome lib 😄

I'm trying to prefix files in a folder with indexes but I would like to be able to do it in a specific order, e.g.: in order of size, addition date, etc...

I would be willing to work in such a feature and submit a PR if you think it's a good idea! I believe we could use Node's fs.Stats Class properties to be able to specify an order-by property and do the ordering before mapping over the files array.

What do you think about this?

75lb commented 6 years ago

hi, that sounds like a good idea thanks. Feel free to work on an order-by feature and share the results with me. If the feature benefits other users I may include it in a future release.

ebastidas commented 6 years ago

@tibuurcio would appreciate a lot this new feature!

75lb commented 6 years ago

Work on this feature is in progress. In the next version you will be able to supply a file list via stdin, giving you full control over the files processed and their order. In this example, input comes from the output of find via sort:

$ find . | sort --reverse | renamer --find one --replace two

For the most precision, you could hand-roll a file containing one filename per line and pipe it into renamer.

$ cat file-list.txt | renamer --find one --replace two
75lb commented 6 years ago

Renamer v1 prerelease is available to test, see here. Does that solve your issue?

tibuurcio commented 6 years ago

Hi @75lb, this solves my issues very well. It's even more robust than my first approach since we can use a file containing filenames. Thank you very much for working on this 👍

We can close this issue now since it's resolved!

75lb commented 6 years ago

Pleased to hear your issue is resolved. I'll close this ticket once v1 goes live. If there are any other features you are lacking, now would be a good time to speak!

75lb commented 6 years ago

fixed and released in renamer v1.0.0.