Trim after a specific character

Bulk Rename Utility How-To's

Trim after a specific character

Postby renamewhat » Mon Feb 05, 2024 1:40 pm

Hello, need some help, I have this kind of name pattern:

Test_01_47-06_9ae2384b
Test_01_47-07_df995
Test_01_47-09_a6a

I need to rename these folders so they look like this:

Test_01_47-06_
Test_01_47-07_
Test_01_47-09_

Basically everything should be trimmed after the third _ character.

Any help would be appreciated. Thanks
renamewhat
 
Posts: 2
Joined: Mon Feb 05, 2024 1:33 pm

Re: Trim after a specific character

Postby Admin » Tue Feb 06, 2024 5:24 am

RegEx (1)
Enable Simple

Match: %1_%2_%3_%4
Replace: %1_%2_%3_
Admin
Site Admin
 
Posts: 2354
Joined: Tue Mar 08, 2005 8:39 pm

Re: Trim after a specific character

Postby renamewhat » Tue Feb 06, 2024 8:19 am

Thank you so much.
renamewhat
 
Posts: 2
Joined: Mon Feb 05, 2024 1:33 pm

Re: Trim after a specific character

Postby frankliniwobi » Wed Apr 10, 2024 7:48 am

Please what if I want to move everything after the extension to before the eztension and format it? For example, I have

capabilities.jpg&w=2048&q=75
logo.jpg&w=657&q=75
bg.jpg&w=1080&q=85

And want to change it to

capabilities-w-2040-q-75.jpg
logo-w-657-q-75.jpg
bg-w-1080-q-85.jpg

How do I achieve it?
frankliniwobi
 
Posts: 2
Joined: Wed Apr 10, 2024 7:40 am

Convert/Move extra characters after extensions

Postby Luuk » Thu Apr 11, 2024 3:33 am

@Frankliniwobi
First to put a checkmark inside for the menu... Renaming Options, File/Folder Extensions, Rename File Extensions.
Then for your examples, Regex(1) could use a "Match" and "Replace" like...
(.+)(\.jpg)&(w)=(\d+)&(q)=(\d+)$
\1-\3-\4-\5-\6\2

After finished renaming, its always best to remove the checkmark for renaming extensions.
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm

Re: Trim after a specific character

Postby frankliniwobi » Sat Apr 20, 2024 1:58 pm

@Luuk

Thank you very much, it worked perfectly :D

I have another question, there's a folder with similar type of files but this time around I want to remove everything after the extension.

For example,

capabilities.jpg&w=2048&q=75
logo.jpg&w=657&q=75
bg.jpg&w=1080&q=85

Converted to

capabilities.jpg
logo.jpg
bg.jpg

I tried to modify the previous code from

(.+)(\.jpg)&(w)=(\d+)&(q)=(\d+)$
\1-\3-\4-\5-\6\2

to

(.+)(\.jpg)&(w)=(\d+)&(q)=(\d+)$
\1\2

But it did not work, Please help
frankliniwobi
 
Posts: 2
Joined: Wed Apr 10, 2024 7:40 am

Convert/Move extra characters after extensions

Postby Luuk » Sat Apr 20, 2024 10:53 pm

@Frankliniwobi
Can just put a checkmark back inside for renaming the file extensions.
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm


Return to How-To


cron