add rename counters; closes #854

This commit is contained in:
ed 2025-10-04 11:53:59 +00:00
parent 09e6f29e5e
commit d05a88d2ee
2 changed files with 7 additions and 2 deletions

View file

@ -998,6 +998,8 @@ available functions:
* `$lpad(text, length, pad_char)`
* `$rpad(text, length, pad_char)`
two counters are available; `.n.s` is the nth file in the selection, and `.n.d` the nth file in the folder, for example rename-output `file(.n.d).(ext)` gives `file5.bin`, and `beach-$lpad((.n.s),3,0).(ext)` is `beach-017.jpg`
so,
say you have a file named [`meganeko - Eclipse - 07 Sirius A.mp3`](https://www.youtube.com/watch?v=-dtb0vDPruI) (absolutely fantastic album btw) and the tags are: `Album:Eclipse`, `Artist:meganeko`, `Title:Sirius A`, `tn:7`

View file

@ -15933,7 +15933,8 @@ var fileman = (function () {
r.rename = function (e) {
ev(e);
var sel = msel.getsel();
var sel = msel.getsel(),
all = msel.all;
if (!sel.length)
return toast.err(3, L.fr_emore);
@ -15957,9 +15958,11 @@ var fileman = (function () {
return toast.err(0, esc('bug:\n' + base + '\n' + vsp[0]));
var vars = ft2dict(ebi(sel[a].id).closest('tr'));
mkeys = vars[1].concat(vars[2]);
mkeys = [".n.d", ".n.s"].concat(vars[1], vars[2]);
var md = vars[0];
md[".n.s"] = '' + (1 + a);
md[".n.d"] = '' + (1 + all.indexOf(sel[a]));
for (var k in md) {
if (!md.hasOwnProperty(k))
continue;