It's embarrassing - I just can't figure out a really easy rename pattern. I know how to do it in other programs, but thought I'd speed it up with XY.
Well over 200,000 jpgs must be renamed to conform to new product numbers. These numbers (=filenames) have the exact same pattern and 12-digit length. Task: Select them batchwise by certain suffixes (easy to do with Better File Selector), then remove/ add/ some parts to reflect new supplier codes. No fancy search/replace actions. It's all plain positions only.
Example: Remove digits 8-11 from the selected files.
I am sitting in UDC, category Rename, Type "Batch Rename Pattern".
What do I enter? Could someone help me out, please?
UDC to rename selection
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: UDC to rename selection
Well based on your example you'd want to use a regular expression rename instead of batch.
The "simplest" pattern would be: ^(.{7})(.{4})(.*\.[^\.]*)$ > $1$3
Note that I only captured the four characters in the middle to more easily show what is removed.
EDIT: Another useful more visual explanation. /edit
That said, you could also do me a favor and instead give these old scripts a try: http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=2316
I haven't been a good steward in keeping them up to date, so I'm curious if they are broken and how badly.
The Regexp-Filename script has a subscript 'Remove n characters starting after character x' which should do what you want if you use values of x=7 and n=4.
The "simplest" pattern would be: ^(.{7})(.{4})(.*\.[^\.]*)$ > $1$3
Note that I only captured the four characters in the middle to more easily show what is removed.
EDIT: Another useful more visual explanation. /edit
That said, you could also do me a favor and instead give these old scripts a try: http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=2316
I haven't been a good steward in keeping them up to date, so I'm curious if they are broken and how badly.
The Regexp-Filename script has a subscript 'Remove n characters starting after character x' which should do what you want if you use values of x=7 and n=4.
-
Stef123
Re: UDC to rename selection
Thanks for your quick help. And for putting "simple" in quotes -
very appropriate. It threw me off completely. As much as I admire RegEx afficionados, I was hoping for the Jack&Jill version, the usual stuff like "Remove [start-#;length-#]"
The dialog of your script (Filename.xys) does exactly what I hoped for:
Position at which to start, then Number of characters to remove.
Followed by .... <Unchanged> for all files
Not working, it only produces an insane RegEx pattern in the preview dialog.
EDIT:
I am getting confused: Did you mean to indiciate there is no other way to do this except for RegEx?
Followed your links to RegEx, understood nothing, but pasted it anyway, no joy. XY's answer: <invalid>
The dialog of your script (Filename.xys) does exactly what I hoped for:
Position at which to start, then Number of characters to remove.
Followed by .... <Unchanged> for all files
EDIT:
I am getting confused: Did you mean to indiciate there is no other way to do this except for RegEx?
Followed your links to RegEx, understood nothing, but pasted it anyway, no joy. XY's answer: <invalid>
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: UDC to rename selection
Drats! I'll need to look into those when I find the time. Thanks for checking and sorry they don't work anymore!Stef123 wrote:Followed by .... <Unchanged> for all files![]()
Not working, it only produces an insane RegEx pattern in the preview dialog.
Unfortunately, a regular expression that can handle all cases quickly becomes rather complicated. My previous suggestion was attempting to protect you file extensions.Stef123 wrote:Thanks for your quick help. And for putting "simple" in quotes -![]()
![]()
very appropriate. It threw me off completely. As much as I admire RegEx afficionados, I was hoping for the Jack&Jill version, the usual stuff like "Remove [start-#;length-#]"
If instead you take more care in when and how you use the rename then you could get by with: ^(.{7}).{4} > $1
This will match the first 11 characters - capturing the first 7 of those as $1.
And then replace the entire match, all 11 characters, with the captured value, those first 7.
As I said you need to take special care with this one, and what I mean by that is...
This does not attempt to protect the extension so if you give it a filename of '1234567.9AB' (11 characters long) it will turn it into '1234567', removing the last 4 characters which happen to be the extension.
The real take away is don't use this if the base name of the item is less than 11 characters long, as it will destroy the extension.
Example - note that unlike above it captures the .{4} to highlight what is removed.
Not sure why XY was showing you invalid it should look like this:
To see the attached files, you need to log into the forum.
-
Stef123
Re: UDC to rename selection
I appreciate your good intentions, TheQwerty, I really do. Like you said, RegEx quickly becomes complicated. Not what I call user-friendly for such an easy task, so I ended up using an old tool from stone age:
The problem with such external renames: XY takes extra time re-creating the thumbnail cache when I come back. To counter these performance lags, I had to cut the folder into smaller ones, then merging them back together.
This has been a negative experience. Not in the mood for working overtime again. Today I am off to work with other file managers again.
The problem with such external renames: XY takes extra time re-creating the thumbnail cache when I come back. To counter these performance lags, I had to cut the folder into smaller ones, then merging them back together.
This has been a negative experience. Not in the mood for working overtime again. Today I am off to work with other file managers again.
To see the attached files, you need to log into the forum.
-
Regmos
- Posts: 268
- Joined: 22 Dec 2012 07:27
- Location: Copenhagen
Re: UDC to rename selection
For what it's worth. I'm an even bigger Regex noob, so whenever i stumpleupon a usefull expression (like this), I save it in my PhraseExpress (always running) with a meaningful title.Stef123 wrote:... RegEx quickly becomes complicated...
That way, all I have to do is start RegExp Rename..., type the abbrevation (regre), choose the right one from the popup, edit the numbers if needed, hit Preview... > OK and I'm done.

Kind regards
Regmos
Regmos
-
Stef123
Re: UDC to rename selection
Thanks Regmos. It's not a matter of remembering XY syntax, though. It's about having to deal with that kind of syntax in the first place.
Nothing against RegEx to cover crazy char-combinations. But to rename a repeating 12-digit pattern, I shouldn't have to depend on forum help. Not to mention that I couldn't get it work, alienated co-workers, made a fool of myself, and of XY too, btw.
To cope with the XY interface in general, here's my tip in return - instead of Phrase Express, try this help script
http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=11887
until this gets implemlented:
http://www.xyplorer.com/xyfc/viewtopic. ... 15#p106583
Nothing against RegEx to cover crazy char-combinations. But to rename a repeating 12-digit pattern, I shouldn't have to depend on forum help. Not to mention that I couldn't get it work, alienated co-workers, made a fool of myself, and of XY too, btw.
To cope with the XY interface in general, here's my tip in return - instead of Phrase Express, try this help script
http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=11887
until this gets implemlented:
http://www.xyplorer.com/xyfc/viewtopic. ... 15#p106583
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: UDC to rename selection
That's a great use for those macro/auto-complete tools Regmos!
There's also sticky sections built into most XYplorer lists that can serve a similar purpose:
Regular expressions are really indispensable and not learning even the basics of them is only a disservice to yourself.
It's hard to top the productivity improvement you can gain by spending an afternoon going through http://www.regular-expressions.info/quickstart.html
There's also sticky sections built into most XYplorer lists that can serve a similar purpose:
And I believe for rename patterns you can either caption them or for regexp use a regular expression comment, but I'm not in a position to verify this at the moment.Sticky Section: Various most-recently-used (MRU) lists can have an optional Sticky Section. Items in
the Sticky Section are permanent members of this list and will never be pushed out when new items
are added. You can use this section for your all-time favorite items and carefully crafted patterns. The
Sticky Section can be added via List Management, simply add this dummy item as section separator:
-----> mru
Everything above this line is in the Sticky Section. Everything below this line is in the MRU Section. So
the Sticky Section is always displayed on top of the whole list.
Many MRU lists support a Sticky Section, e.g.: Address Bar & Go to, Find Files: Name, Find Files:
Location, Rename Special: (...), Visual Filters, Selection Filters, Move/Copy/Backup To, Recently Opened
Files, Recent Catalogs, Recently Included Catalogs.
Regular expressions are really indispensable and not learning even the basics of them is only a disservice to yourself.
It's hard to top the productivity improvement you can gain by spending an afternoon going through http://www.regular-expressions.info/quickstart.html
-
Regmos
- Posts: 268
- Joined: 22 Dec 2012 07:27
- Location: Copenhagen
Re: UDC to rename selection
Yes, PhraseExpress rocks. Use it all the time

Thanks for the reminder. Forgot all about that.There's also sticky sections built into most XYplorer lists that can serve a similar purpose:....

As you can see, I managed to comment the expressions, and it works like expected, but I can't find a way to caption them.And I believe for rename patterns you can either caption them or for regexp use a regular expression comment...
Kind regards
Regmos
Regmos
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: UDC to rename selection
Yep.. looks like I was mistaken on it allowing captions.Regmos wrote:As you can see, I managed to comment the expressions, and it works like expected, but I can't find a way to caption them.
Guess we'll need to ask Don to improve this since it would sure be nice to have friendly names for our sticky items.
XYplorer Beta Club