How do I change "smith james.jpg" to "smithja.jpg"

Bulk Rename Utility How-To's

How do I change "smith james.jpg" to "smithja.jpg"

Postby Franklin » Fri Dec 02, 2022 6:17 pm

I have a last and first name string such as "smith james.jpg" and want to change it to the first four of the last name, and first two of the first name, and removing the space resulting in "smitja.jpg" Some names aren't four letters long, and some people have three parts to their name, but I'm not too worried about those outliers. Thanks for any help. Some examples.

peterson sarah.jpg to petesa.jpg
cox paul.jpg to coxpa.jpg
henderson ariel.jpg to hendar.jpg
Franklin
 
Posts: 1
Joined: Fri Dec 02, 2022 6:12 pm

Re: How do I change "smith james.jpg" to "smithja.jpg"

Postby Admin » Sun Dec 04, 2022 10:59 pm

Hi , this can be done in Javascript very easily, do you have a commercial license for BRU?
Otherwise you can use a RegEx (1) as well.

Enable v2 tick in RegEx(1) then

Match:
(.)(.)(.)(.)(.*) (.)(.)(.*)
Replace:
$1$2$3$4$6$7

Try it out.

thanks
Admin
Site Admin
 
Posts: 2354
Joined: Tue Mar 08, 2005 8:39 pm

Re: How do I change "smith james.jpg" to "smithja.jpg"

Postby therube » Mon Dec 05, 2022 6:10 pm

(Actually, that RegEx fails [as has everything I have tried].
Where is Luke when we need him ;-).)


Heh.
While we're at it, in Replace:
is $1 interchangeable with \1 ?
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: How do I change "smith james.jpg" to "smithja.jpg"

Postby Admin » Tue Dec 06, 2022 12:08 am

Hi therube, did you try with RegEx version 2? It works for me.

is $1 interchangeable with \1 ?


In V2, yes 8)
Admin
Site Admin
 
Posts: 2354
Joined: Tue Mar 08, 2005 8:39 pm

Re: How do I change "smith james.jpg" to "smithja.jpg"

Postby therube » Fri Dec 30, 2022 5:14 pm

Code: Select all
did you try with RegEx version 2?

Well yes, I did.
But what I did, at the time & obviously incorrectly, had not worked.

Anyhow, you're right, it does work.
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm


Return to How-To