Created attachment 111136 [details] Example "part of filename" screenshot Using the part-of-filename function in KRename (e.g. [$1;5] or [$1-[length]]) does not count special characters like '&', '%', '#' and shortens the result by the number of these. If a special character is at the end of the filename-part '\' is inserted. E.g. [$2-[length]] "1234#6789.txt" -> "234#678.txt" (expected: "234#6789.txt")[$2-[length]] "12&&567.txt" -> "2&&5.txt" (expected: "2&&567.txt") [$2;3] "123%56.txt" -> "23\.txt" (expected: "23%.txt") Tested with KRename 4.0.9 (Kubuntu 17.10 packages) and 5.0.60 (git master).
Indeed the findLength() function only uses name.length(), without first unescaping tokens. https://cgit.kde.org/krename.git/tree/src/batchrenamer.cpp#n1064
Similar issue for findPartStrings()...
Git commit d9f23bd5dc9e87c9613136708dd93ff92ba9bc23 by Heiko Becker. Committed on 21/04/2018 at 15:28. Pushed by heikobecker into branch '5.0'. Escape/unescape filenames with special characters M +10 -1 src/batchrenamer.cpp https://commits.kde.org/krename/d9f23bd5dc9e87c9613136708dd93ff92ba9bc23