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.
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