Batch Rename Patterns

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Jeff Bellune
Posts: 284
Joined: 13 Dec 2007 12:55

Batch Rename Patterns

Post by Jeff Bellune »

Without resorting to RegExp or Scripts, are there pattern wildcards or placeholders that will let me manipulate characters in the middle of base file names, or delete characters anywhere in the file name? For example, I ripped some of my CDs a while back using the format 01-<track name>.flac, 02-<different track name>.flac, etc. For display, tagging and media server reasons I'd like to get rid of the hyphen between the two-digit track number and the track name and replace it with a space.

For other rips, sometimes the online database would add a disk number and I'd get 1.01-<song name>.flac. So in that case I need to delete the 1. as well as do the hyphen/space thing.

A third example is the database adding (Live) to every track name on a live album. Maybe it's handy if I'm doing a flat view search on a media server and I need to know if Back In Black is the live or studio version, but most of the time it's just annoying. I'd like to rename the files by deleting the (Live) suffix. Search and Replace seems like a good candidate for this one, but I haven't found a workable pattern yet.

Thanks,
Jeff

highend
Posts: 14925
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Batch Rename Patterns

Post by highend »

You can't do that with e.g. batch rename. The safest (and most flexible way) is the regexp way...

- Replaces only the first hyphen
01-<track name>.flac
to
01 <track name>.flac

Code: Select all

^(\d+)-(.*) > $1 $2
- Replaces any leading [0-9]. and the first hyphen
1.01-<song name>.flac
to
01 <song name>.flac

Code: Select all

^(\d\.)(\d+)-(.*) > $2 $3
- This could be done with search and replace but the regex version strips any unnecessary leading or trailing spaces as well
01 song name (Live).flac
to
01 song name.flac

Code: Select all

\s*\(live\)\s* > 
One of my scripts helped you out? Please donate via Paypal

Jeff Bellune
Posts: 284
Joined: 13 Dec 2007 12:55

Re: Batch Rename Patterns

Post by Jeff Bellune »

Hello highend,

Thank you for those expressions. They work great! I wanted to avoid getting into RegEx but I think I don't have much choice any more... :mrgreen:

Cheers,
Jeff

Quaraxkad
Posts: 183
Joined: 20 Apr 2014 18:01

Re: Batch Rename Patterns

Post by Quaraxkad »

Jeff Bellune wrote:Thank you for those expressions. They work great! I wanted to avoid getting into RegEx but I think I don't have much choice any more... :mrgreen:

If you rename a lot, RegExp will make your life MUCH easier!

Stef123

Re: Batch Rename Patterns

Post by Stef123 »

Jeff Bellune wrote:I wanted to avoid getting into RegEx but I think I don't have much choice any more... :mrgreen:
Try RenameMaster http://www.joejoesoft.com/vcms/108/
It integrates nicely into XY (selected files are passed on) and manages your tasks without RegEx on the user interface. Try out the provided example scripts like EG-SwapAroundDash.rmscr and pare down the interface to what you really need.

Jeff Bellune
Posts: 284
Joined: 13 Dec 2007 12:55

Re: Batch Rename Patterns

Post by Jeff Bellune »

^^^^

Thanks. It looks promising!

I suppose I'll find this out after installing it and nosing around a bit, but how do files in XY get passed to RenameMaster?

Cheers,
Jeff

Stef123

Re: Batch Rename Patterns

Post by Stef123 »

Jeff Bellune wrote:I suppose I'll find this out after installing it and nosing around a bit, but how do files in XY get passed to RenameMaster?
I carry the portable version around with me, and the following UserDefinedCommand is triggered when I press F2:

Category: Open with
Application: ..\RenameMaster\RenameMaster.exe
Mode: Single Instance

I multi-select a bunch of files, then press F2, RenameMaster opens with the active-tab path, tick marks for all checkboxes enabled that correspond to my active selection in XY

Jeff Bellune
Posts: 284
Joined: 13 Dec 2007 12:55

Re: Batch Rename Patterns

Post by Jeff Bellune »

Stef123 wrote: Category: Open with
Application: ..\RenameMaster\RenameMaster.exe
Mode: Single Instance

I multi-select a bunch of files, then press F2, RenameMaster opens with the active-tab path, tick marks for all checkboxes enabled that correspond to my active selection in XY
Thanks! I can't wait to try it. :)

Cheers,
Jeff

m_l_oliver@yahoo.com
Posts: 3
Joined: 03 Dec 2023 07:45

Re: Batch Rename Patterns

Post by m_l_oliver@yahoo.com »

This is a somewhat helpful discussion, showing a limited variety of tokens being used.
It's frustrating that the knowledgeable discussion responders forgot to mention the help documents that more fully describe the tokens they use in their response.
This may seem like a minor point, but it seems fairly important to me since, after an hour of investigating, the XYplorer app itself is pointing me to help aids that offer little knowledge about the universe of regular expression tokens. Maybe I am (or the XYplorer app is) am overlooking something obvious.

highend
Posts: 14925
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Batch Rename Patterns

Post by highend »

RegExps aren't bound to XY, they exist far longer and in countless applications.

If you need guidance of what XY actually uses, google for: vbscript regular expressions
One of my scripts helped you out? Please donate via Paypal

m_l_oliver@yahoo.com
Posts: 3
Joined: 03 Dec 2023 07:45

Re: Batch Rename Patterns

Post by m_l_oliver@yahoo.com »

Your google suggestion is very helpful. :)
I wish the XYplorer help aids would have included that same advice. It would save some serious time for me and others. Including the 'vbscript' argument for google searching is great to know too since it helps the search focus in on the appropriate flavor of regular expressions. I would have missed the 'vbscript' term completely except for your helpful advice.
Much appreciated.

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

Re: Batch Rename Patterns

Post by admin »

I'll add that to the Help, thanks! :tup:

Post Reply