Hi
Spaces in variable
I created a button that add trailing number to files or folders so that for example: "test.mp3" files or "test" folders results "test - 01.mp3" and "test - 01" and so on.
I had to use variables so that it works for files as well as folders. Plus variables allows to choose options order:
@nodeselect
@runonce:@set num={dlgstring|Enter leading number|01}
@runonce:@set sep={dlgstringS|Enter a separator, a space or nothing|" - "}
Rename TYPE=files NUMBER {$num} REGEXP PATTERN="(.*)(\.[^.]+)$" TO="\1{$sep}[#]\2" autorename
Rename TYPE=dirs NUMBER {$num} REGEXP PATTERN="(.*)" TO="\1{$sep}[#]" autorename
But spaces filled in alone or around a separator such as [ - ] aren't taken into account in the new name, I get "test-01.mp3" instead of "test - 01.mp3". Tough, {$sep} = [ - ] and not [-].
So I have to change
...
TO="\1{$sep}[#]\2"
...
into
...
TO="\1 {$sep} [#]\2"
...
It's not logical because this code works:
@nodeselect
Rename TYPE=files NUMBER {dlgstring|Enter leading number|01} REGEXP PATTERN="(.*)(\.[^.]+)$" TO="\1{dlgstringS|Enter a separator, a space or nothing|" - "}[#]\2" autorename
Conclusion of my various tests: variables don't take in account leading and trailing spaces.
Do I do something wrong here ?
Who will take up the challenge to get their hands dirty ?
Unless it's a bug. In this case advanced users need to confirm it.
You can do it !