Incrementing number by regexp
Posted: 02 Oct 2015 12:11
I have to rename files. If there is a number at the end of the filename it has to be incremented. If there weren't any numbers at the end, "1" should be added to the filename.
test -> test1
test5 -> test6
test65a -> test65a1
My solution works:
But is there any other, rather more elegant way to achieve this? Preferably with the "rename r," command, which could work on more files at once?
test -> test1
test5 -> test6
test65a -> test65a1
My solution works:
Code: Select all
renameitem(regexreplace("<curbase>","^(.*?)(\d*)$","$1") . regexreplace("<curbase>","^(.*?)(\d*)$","$2")+1);