Problem with RegEx Renaming scripts

Discuss and share scripts and script files...
Post Reply
Mesh
Posts: 956
Joined: 24 Mar 2008 21:22

Problem with RegEx Renaming scripts

Post by Mesh »

I just started playing with scripts in XY, and I hit a bit of confusion.

I'm basically trying to code a script that runs several RegEx renames. However, what I'm finding is that rather than acting on all the selected files, it only acts on the files that the very first regex matches.

Even if I add code to reselect every file in the folder in between every single RegEx Rename, it still only acts on the files matched by the very first RegEx.


Is this a bug, or did I make a mistake?

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

Re: Problem with RegEx Renaming scripts

Post by jacky »

hmm... no the rename command should apply to all selected items. Of course, only those with names matching your regexp will be renamed, but since selection remains the same after renaming, there's no reason other rename operation don't apply to all selected items.

I do have scripts that do multiple (regexp) rename operations in a row, and they are applied to all selected items without trouble.
Mesh wrote:Even if I add code to reselect every file in the folder in between every single RegEx Rename, it still only acts on the files matched by the very first RegEx.
So you select all files, do a regexp rename, and yet only files matching a previous regexp are affected !?? Sounds really odd indeed... Does that happen whatever the regexp used ? Could you share a little script with only two or three calls to rename that work that way ?
Proud XYplorer Fanatic

Mesh
Posts: 956
Joined: 24 Mar 2008 21:22

Re: Problem with RegEx Renaming scripts

Post by Mesh »

I am happy for XY, but ashamed for myself, to say that this was a false alarm and the issue was caused by a coding error on my part.

In coding the script, I copied over RegEx's that I assembled in another text file which came from the manual renaming steps I had been using in XY. However, in the process of copying them over, a single line was missed which made all the difference.

My script syntax was fine, and the manual steps worked exactly as they should from top to bottom - so it appeared to be something else.


Please forgive me for bringing this up, and feel free to delete this thread. :)

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

Re: Problem with RegEx Renaming scripts

Post by admin »

Mesh wrote:Please forgive me for bringing this up, and feel free to delete this thread. :)
I'll preserve it as a warning example. :P

Mesh
Posts: 956
Joined: 24 Mar 2008 21:22

Re: Problem with RegEx Renaming scripts

Post by Mesh »

admin wrote:
Mesh wrote:
Please forgive me for bringing this up, and feel free to delete this thread. :)
I'll preserve it as a warning example. :P

Why do you hate me? :mrgreen:

Post Reply