Page 1 of 1

Remove all characters after a defined set of characters?

PostPosted: Sat Mar 12, 2022 11:09 am
by vendo_23
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

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

PostPosted: Sat Mar 12, 2022 4:40 pm
by Luuk
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.

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

PostPosted: Sat Mar 12, 2022 9:35 pm
by vendo_23
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!

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

PostPosted: Sat Apr 30, 2022 12:44 am
by Luuk
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.