Remove all characters after a defined set of characters?

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Remove all characters after a defined set of characters?

Postby vendo_23 » Sat Mar 12, 2022 11:09 am

Hi, I have a bunch of files with various numbers in parenthesis such as "(197)", "(205)", etc, with a bunch of characters after. I need to have BRU automatically remove anything after the number. Is there a way to have BRU check a list of all available numbers (let's say "(190)" through "(210)"), then remove any characters that come after?

Example:
From > filename(198)DQrrtfo1.5.4loz.txt
To > filename(198).txt

Thank you
vendo_23
 
Posts: 2
Joined: Sat Mar 12, 2022 3:37 am

Re: Remove everything after (190) through (210)

Postby Luuk » Sat Mar 12, 2022 4:40 pm

To remove everything after (190) through (210), the RegEx(1) can use a "Match" and "Replace" like...
(.+\((19\d|20\d|210)\)).*
\1
Can change the ".+" into something like "filename" to only conduct names like the example.
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: Remove everything after (190) through (210)

Postby vendo_23 » Sat Mar 12, 2022 9:35 pm

Luuk wrote:To remove everything after (190) through (210), the RegEx(1) can use a "Match" and "Replace" like...
(.+\((19\d|20\d|210)\)).*
\1
Can change the ".+" into something like "filename" to only conduct names like the example.



I appreciate the reply and the info...could you please also help in generating an example of the whole code? I am trying to figure out the syntax and everything for how to add the start directory and destination directory. I can't seem to find any help for the command line version of this utility and I am very new to it. Thank you!
vendo_23
 
Posts: 2
Joined: Sat Mar 12, 2022 3:37 am

Command-line: Remove all chars after (190->210)

Postby Luuk » Sat Apr 30, 2022 12:44 am

Im afraid your question gets posted to the wrong area, instead of the section for the command-line brc64.exe?
So you can start experimenting on the command-line with something like...
"C:\PathTo\Your\brc64.exe" /Dir:"C:\PathToFolder\WithFilesToRename" /Pattern:*(*)*.txt /RegExp:"(.+\((19\d|20\d|210)\)).*:\1"

The experiment is for txt-files like in the description, and it only renames if (this) is from 190-210.
Add /Recursive to recurse into all of the sub-folders.. Add /Execute when you're ready to rename.
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm


Return to BRU Support