How to delete whole section of a filename between ( and )

Bulk Rename Utility How-To's

How to delete whole section of a filename between ( and )

Postby mwidunn » Mon Dec 23, 2024 6:53 pm

Let's say I have a Filename:

ThisIsTheFile (xxxxxxxxx).docx

But, I want to delete only the section of the Filename in parentheses, that is, (xxxxxxxxx).

How do I do this?

Thanks!
mwidunn
 
Posts: 5
Joined: Mon Nov 14, 2016 7:29 pm

Re: How to delete whole section of a filename between ( and )

Postby Admin » Tue Dec 24, 2024 12:57 am

There are different ways to do this:

Replace (3)
Replace: (*) <---- (*) with a space in front.
Match: <--- replace with nothing = remove it

RegEx (1):
Match: \(.*\) <---- \(.*\) with a space in front.
Replace: <--- replace with nothing = remove it

RegEx (1): with Simple Flag Enabled
Match: %1 (%2)
Replace: %1

Remove (5)
Crop: Special -> (*) <---- (*) with a space in front.

File Segment + Name (2)
File segment -> From set to ( <----- a ( with a space in front
and
Nme (2) -> Remove

Javascript Function
// Find the position of the opening and closing parentheses
openParenIndex = name.indexOf(' (');
closeParenIndex = name.indexOf(')');
// If both parentheses are found, remove the part inside them
if (openParenIndex !== -1 && closeParenIndex !== -1) {
newName = name.substring(0, openParenIndex) + name.substring(closeParenIndex + 1);
}
Admin
Site Admin
 
Posts: 2883
Joined: Tue Mar 08, 2005 8:39 pm

Re: How to delete whole section of a filename between ( and )

Postby mwidunn » Mon Dec 30, 2024 11:58 pm

Admin wrote:There are different ways to do this:

Replace (3)
Replace: (*) <---- (*) with a space in front.
Match: <--- replace with nothing = remove it ~~~~~~~~~~~~~YES, THIS WORKED!

RegEx (1):
Match: \(.*\) <---- \(.*\) with a space in front.
Replace: <--- replace with nothing = remove it~~~~~~~~~~~~~Actually, I didn't test this one

RegEx (1): with Simple Flag Enabled
Match: %1 (%2)
Replace: %1~~~~~~~~~~~~~YES, THIS WORKED!

Remove (5)
Crop: Special -> (*) <---- (*) with a space in front.~~~~~~~~~~~~~NO, THIS DID NOT WORK! (Wish I could show an image without having to insert from http)

File Segment + Name (2)
File segment -> From set to ( <----- a ( with a space in front
and
Nme (2) -> Remove~~~~~~~~~~~~~I did not test this one. For any one file, I would just highlight the segment and delete it.

Javascript Function
// Find the position of the opening and closing parentheses
openParenIndex = name.indexOf(' (');
closeParenIndex = name.indexOf(')');
// If both parentheses are found, remove the part inside them
if (openParenIndex !== -1 && closeParenIndex !== -1) {
newName = name.substring(0, openParenIndex) + name.substring(closeParenIndex + 1);
}~~~~~~~~~~~~~YES, THIS WORKED! But, presumably, the script cannot be saved; it must be done each time.[/b]
[b]

Thanks for your help!
mwidunn
 
Posts: 5
Joined: Mon Nov 14, 2016 7:29 pm

Re: How to delete whole section of a filename between ( and )

Postby Admin » Tue Dec 31, 2024 4:10 am

Hi, yes the Javascript is also saved when saving all settings to a .bru file with the "save" command.
Admin
Site Admin
 
Posts: 2883
Joined: Tue Mar 08, 2005 8:39 pm


Return to How-To