Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folder index replace in reverse order #32

Closed
ebastidas opened this issue Jan 7, 2018 · 3 comments
Closed

Folder index replace in reverse order #32

ebastidas opened this issue Jan 7, 2018 · 3 comments

Comments

@ebastidas
Copy link

ebastidas commented Jan 7, 2018

This issue might be an extension of #31 or a bug of the current code.

I needed to rename folders using {{index}}, and I don't know if the current code has a bug because it incorrectly sorts the folders in descending order instead of ascending order (which is the correct order). This only happens in renaming folders, but it works fine when renaming files.

I'm using this command:

renamer --replace '{{index}}' *

When renaming (text) files, it correctly produce:

IMG_5776.txt -> 1
IMG_5777.txt -> 2
IMG_5778.txt -> 3

But with folders it happens the following:

IMG_5778 -> 1
IMG_5777 -> 2
IMG_5776 -> 3

To fix temporarily my issue to rename folders correctly I changed this line (https://github.com/75lb/renamer/blob/master/lib/renamer.js#L59):

results.list = options.files.map(replaceSingle.bind(null, findRegex, options.replace))

to

results.list = options.files.reverse().map(replaceSingle.bind(null, findRegex, options.replace))

But this would obviously brake the functionality of files renaming using index. @75lb Would be nice is this issue would be address. Thanks

@75lb
Copy link
Owner

75lb commented May 23, 2018

Reproduced, looking into this.

@75lb
Copy link
Owner

75lb commented Jun 17, 2018

Is this still an issue in renamer v1?

@75lb
Copy link
Owner

75lb commented Jul 17, 2018

fixed and released in renamer v1.0.0.

@75lb 75lb closed this as completed Jul 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants