Regexp "counters"

Features wanted...
jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Regexp "counters"

Post by jacky »

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! :D

What do you think of it?

admin
Site Admin
Posts: 66258
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Regexp "counters"

Post by admin »

Yes, great.

Sorry, I don't even have time to read this post, let alone understand :wink: Maybe you users can work something out and then present it to me in form of tight abstract :D

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

so.. nobody else would love this? :cry:

RalphM
Posts: 2089
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Post by RalphM »

jacky wrote:so.. nobody else would love this? :cry:
Well I probably would, if the task of renaming big bunches of files like that was daily business, but it just isn't.
And for just a couple of files I'm definitely faster doing it manually than creating a complex regexp.
Ralph :)
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

I'm bumping this just in case ;)
RalphM wrote:And for just a couple of files I'm definitely faster doing it manually than creating a complex regexp.
Speaking of which, Could we have a way to "save" some regexp. I like them very much, but I dont speak the language fluently ;) and I got a couple of regexp that I use regulary and would not "loose".
I know we have an MRU list, but I wish there would be some I could choose not to be removed no matter how old they could get :) (even as a hidden INI trick or something ;))
Actually, I'd like that for the visual filter as well 8)

And speaking of MRU, the location field on Find tab has one, but I have many times the same entries, but the ones I've used most recently arent there at all :?

admin
Site Admin
Posts: 66258
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

jacky wrote:Speaking of which, Could we have a way to "save" some regexp.
Save them in a text file? :P BTW, if you don't speak regexp, you will also want to save what they mean....
jacky wrote:And speaking of MRU, the location field on Find tab has one, but I have many times the same entries, but the ones I've used most recently arent there at all :?
"same entries"?? Not possible. But I will replace the Find tab combos anyway with better controls avec autocomplete as in address bar.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

admin wrote:
jacky wrote:Speaking of which, Could we have a way to "save" some regexp.
Save them in a text file? :P BTW, if you don't speak regexp, you will also want to save what they mean....
hehe :P yeah I did, but I thought a [RegExpRename] could have the ones to always be on the list ;)
And, I know what they mean, just meant some are a bit "complicated" and i wouldn't like to have to rewrite them ;)
admin wrote:
jacky wrote:And speaking of MRU, the location field on Find tab has one, but I have many times the same entries, but the ones I've used most recently arent there at all :?
"same entries"?? Not possible. But I will replace the Find tab combos anyway with better controls avec autocomplete as in address bar.
Not possible?? look at this (from my XYplorer.ini)

Code: Select all

[LookIn]
Count=32
LookIn0=r:\ | h:\ | j:\ | d:\ | n:\ | o:\ | t:\ | i:\ | l:\ | x:\ | e:\ | f:\ | g:\
LookIn1=d:\ | e:\ | h:\ | j:\ | l:\ | r:\ | t:\ | x:\
LookIn2=d:\ | e:\ | h:\ | j:\ | l:\ | r:\ | t:\ | x:\
LookIn3=d:\ | e:\ | h:\ | j:\ | l:\ | r:\ | t:\ | x:\
LookIn4=d:\ | e:\ | h:\ | j:\ | i:\ | l:\ | r:\
LookIn5=Z:\bin\
LookIn6=Z:\bin\
LookIn7=Z:\bin\
LookIn8=Z:\bin\
LookIn9=Z:\bin\
LookIn10=Z:\bin
LookIn11=Z:\bin\
LookIn12=Z:\bin\
LookIn13=Z:\bin\
LookIn14=Z:\bin\
LookIn15=Z:\bin\
LookIn16=Z:\bin\
LookIn17=c:\ | h:\
LookIn18=Z:\bin\
I'm pretty sure some of them are dupes ;)

Gandolf

Post by Gandolf »

jacky wrote:I'm pretty sure some of them are dupes ;)
They certainly look like it! I don't have any duplicates in my list.

admin
Site Admin
Posts: 66258
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

jacky wrote:...[RegExpRename]...
Yeah, this is an interesting idea for all MRU lists: ability to "fix" some entries. Should go along with an MRU list management interface, where you can freely add, remove, rename, reorder, fix... the items. Remind me in 3 months! (No irony :wink: )
jacky wrote:Not possible?? look at this (from my XYplorer.ini)
...
I'm pretty sure some of them are dupes ;)
Looks like. But how do you do it?? I did not manage to create any dupes in my list... :?

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

admin wrote:Looks like. But how do you do it?? I did not manage to create any dupes in my list... :?
I'm not really sure. I cleaned the list manually, and already got a few dupes. I am not sure how it happens exactly, but I think it may be linked to the use of templates.
For example, I have a template with location Z:\bin\ which I use a lot, and it was that location I had the most as dupes (and the one I got dupes of again now). Not sure what I have to do exactly to make it happend, I'll try to see later when I got more time. :)
(I'm actually also pretty sure that sometimes location ain't "saved" in the list, ones I typed in manually that is...)

admin
Site Admin
Posts: 66258
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

Wait until the next BETA, because I'm rewriting this part a bit...

guster
Posts: 13
Joined: 18 Jul 2006 21:48

Re: Regexp "counters"

Post by guster »

jacky wrote: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! :D

What do you think of it?
-----------------------------------

Hi,

Please excuse me not consolidating the previous post (It seems well stated). I have several runs of iterated files that need renamed/renumberd in several different directories. The directories also contain files that should not be renamed, so being carefull of crashing filenames is important. Is this commonly done in XYplorer now? (with and without regexp?) Thank you for any pointers.

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Post by jacky »

Well, yes XY has a Batch Rename feature, that allows you to rename files either with a counter (Increment) or datestamps :)
Proud XYplorer Fanatic

admin
Site Admin
Posts: 66258
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Post by admin »

jacky wrote:Well, yes XY has a Batch Rename feature, that allows you to rename files either with a counter (Increment) or datestamps :)
So, jacky, what do you think of your regexp counters now? Are you still missing it a lot? :wink:

guster
Posts: 13
Joined: 18 Jul 2006 21:48

Post by guster »

"... say we have a bunch of files:
File10.txt, File11.txt, File12.txt, File13.txt, File14.txt "

The following is based on zacky's examples:

you do: File(<[0-9]+)\.txt>Files$1<+>.txt
you get: File11.txt, File12.txt, File13.txt, File14.txt, File15.txt

I have t1 through t16 in a bunch of directories. For some directories I need to ratchet t#-end forward or backward. Other trials in the series, and the rest of the directory (some other series' and individual files) should remain as is. This will require regexp, right?

Post Reply