Regexp "counters"
Posted: 06 Nov 2005 20:26
Ok, so I was thinking of the Renaming files w/ Numbers topic that was previously discussed, but I would also love to be able to do something quite different. And I think it could be done in adding it to the regexp rename function that already exists.
The idea would be to be able to search for number(s) on the filename (using [0-9]), and then use it as a "counter".
So you'll need to implement a "new regexp criteria", like <[0-9]
And when we use it, we could have some new options in the results, for example:
still the usual:
$1 number found (ie. 42)
but also some maths operations:
$1<+> number+1 (ie. 43)
$1<-> number-1 (ie. 41)
$1<+4> number+4 (ie. 46)
$1<*2> number*2 (ie. 84)
or a "counter":
$1<c st=2> 2, 3, 4, etc
$1<c st=7 sp=-2> 7, 5, 3, etc
To see how it would actually work, let's say we have a bunch of files:
File10.txt, File11.txt, File12.txt, File13.txt, File14.txt
you do: File(<[0-9]+)\.txt>File$1.txt
you get: File10.txt, File11.txt, File12.txt, File13.txt, File14.txt (no changes, wowu!!)
you do: File(<[0-9]+)\.txt>Files$1<->.txt
you get: File09.txt, File10.txt, File11.txt, File12.txt, File13.txt
you do: File(<[0-9]+)\.txt>Files$1<+10>.txt
you get: File20.txt, File21.txt, File22.txt, File23.txt, File24.txt
you do: File(<[0-9]+)\.txt>Files$1<c st=1>.txt
you get: File1.txt, File2.txt, File3.txt, File4.txt, File5.txt
File: Version 28 is out.txt
you go: (.*?)(<[0-9]+)(.*)>$1$2<+>$3
you get: Version 29 is out.txt
That'd be really awesome!
What do you think of it?
The idea would be to be able to search for number(s) on the filename (using [0-9]), and then use it as a "counter".
So you'll need to implement a "new regexp criteria", like <[0-9]
And when we use it, we could have some new options in the results, for example:
still the usual:
$1 number found (ie. 42)
but also some maths operations:
$1<+> number+1 (ie. 43)
$1<-> number-1 (ie. 41)
$1<+4> number+4 (ie. 46)
$1<*2> number*2 (ie. 84)
or a "counter":
$1<c st=2> 2, 3, 4, etc
$1<c st=7 sp=-2> 7, 5, 3, etc
To see how it would actually work, let's say we have a bunch of files:
File10.txt, File11.txt, File12.txt, File13.txt, File14.txt
you do: File(<[0-9]+)\.txt>File$1.txt
you get: File10.txt, File11.txt, File12.txt, File13.txt, File14.txt (no changes, wowu!!)
you do: File(<[0-9]+)\.txt>Files$1<->.txt
you get: File09.txt, File10.txt, File11.txt, File12.txt, File13.txt
you do: File(<[0-9]+)\.txt>Files$1<+10>.txt
you get: File20.txt, File21.txt, File22.txt, File23.txt, File24.txt
you do: File(<[0-9]+)\.txt>Files$1<c st=1>.txt
you get: File1.txt, File2.txt, File3.txt, File4.txt, File5.txt
File: Version 28 is out.txt
you go: (.*?)(<[0-9]+)(.*)>$1$2<+>$3
you get: Version 29 is out.txt
That'd be really awesome!
What do you think of it?