Regex to remove text at end of file name

A swapping-ground for Regular Expression syntax

Regex to remove text at end of file name

Postby mamaijee » Sat Aug 30, 2025 3:26 pm

I wish to remove from end of filename the following
"space(Z-Library)"

Pls help with a regex and how to keep it permanently in BRU so that it shows up whenever I start BRU

Many thanks

mamaijee
mamaijee
 
Posts: 38
Joined: Sat Apr 30, 2011 5:17 am

Re: Regex to remove text at end of file name

Postby Admin » Sun Aug 31, 2025 8:29 am

To remove the text ` (Z-Library)` from the end of filenames using Bulk Rename Utility (BRU), you can use a Regular Expression in the RegEx (1) section:

1. In the RegEx (1) group, enter this in the Match box:
```
\(Z-Library\)$
```
Explanation:
- `\(` and `\)` escape the parentheses.
- `Z-Library` matches the literal text.
- `$` ensures it matches only at the end of the filename (before the extension).

2. Leave the Replace box empty (to remove the matched text).

3. Make sure "Inc. Ext." is unchecked if you want to apply this only to the filename, not the extension.

---

To keep this regex permanently in BRU so it shows up whenever you start:

- After setting up the regex, save your renaming settings to a `.bru` file via the menu:
`File > Save Settings As...`
- Next time you start BRU, load this `.bru` file via:
`File > Load Settings...`

BRU also automatically loads the last .bru file from the last session when it starts.

This way, your regex to remove ` (Z-Library)` from the end of filenames will be ready to use every time you start Bulk Rename Utility.
Admin
Site Admin
 
Posts: 3054
Joined: Tue Mar 08, 2005 8:39 pm

Re: Regex to remove text at end of file name

Postby mamaijee » Sun Aug 31, 2025 3:25 pm

Thank you very much for detailed help. Really appreciate it. Will save me a lot of time.

Best wishes

mamaijee
mamaijee
 
Posts: 38
Joined: Sat Apr 30, 2011 5:17 am

Re: Regex to remove text at end of file name

Postby mamaijee » Sun Aug 31, 2025 4:40 pm

I am so sorry to get back again. I tried the regex but it doesnt work. I pasted it in Regex 1, then followed your instruction

"2 Leave the Replace box empty (to remove the matched text).

3. Make sure "Inc. Ext." is unchecked if you want to apply this only to the filename, not the extension."

selected books but nothing happens. Where am I going wrong?
mamaijee
 
Posts: 38
Joined: Sat Apr 30, 2011 5:17 am

Re: Regex to remove text at end of file name

Postby Admin » Sun Aug 31, 2025 11:45 pm

Please post example of file names to rename
Admin
Site Admin
 
Posts: 3054
Joined: Tue Mar 08, 2005 8:39 pm

Re: Regex to remove text at end of file name

Postby mamaijee » Mon Sep 01, 2025 12:03 am

Examples of Filenames to rename:

Hailey Jay - Twisted Desires (Vanguard Prep dark romance 1) (Z-Library)
Maya Alden - Bad Boss (Z-Library)
Natasha L. Black - Daddys Secret Baby (Z-Library)
P.H. Nix - Brutal Revelation (Edgewood Academy Elites) (Z-Library)

Thank you
mamaijee
 
Posts: 38
Joined: Sat Apr 30, 2011 5:17 am

Re: Regex to remove text at end of file name

Postby Luuk » Mon Sep 01, 2025 1:09 am

Its unfortunate, but the forum software likes to remove leading spaces!
So with Regex(1) having the checkmark for v2, the "Match" would be like...
\ \(Z-Library\)$

Or Replace(3) could just use a "Replace" like...
\end\ (Z-Library)
Luuk
 
Posts: 835
Joined: Fri Feb 21, 2020 10:58 pm

Re: Regex to remove text at end of file name

Postby Admin » Mon Sep 01, 2025 3:39 am

Yes, it needs a space before it:

<sp>\(Z-Library\)$

where <sp> is a space.

Or also:

\s\(Z-Library\)$

\s means 'space' in regex.
Admin
Site Admin
 
Posts: 3054
Joined: Tue Mar 08, 2005 8:39 pm

Re: Regex to remove text at end of file name

Postby mamaijee » Mon Sep 01, 2025 9:25 pm

Thank you for all your help
mamaijee
mamaijee
 
Posts: 38
Joined: Sat Apr 30, 2011 5:17 am


Return to Regular Expressions