Rename with Pattern

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

Rename with Pattern

Postby rome1349 » Fri Feb 15, 2019 5:34 pm

Hi,
Everyday I will have a data feed which will have this kind of pattern.
product_list_20_20190213.csv
product_list_20_20190214.csv
product_list_20_20190215.csv
product_list_137_20190213.csv
product_list_137_20190214.csv
product_list_137_20190215.csv
and so on (there are actually like hundreds of numbers not only 20 and 137)

What I would like is to turn the
product_list_20 to Apple
product_list_137 to Samsung

And you can see the last 8 characters are the year month date.
it should be converted from 20190213 to 2019-02-13
So from the above sample the outcome should be like.

product_list_20_20190213.csv -> Apple_2019-02-13
product_list_20_20190214.csv -> Apple_2019-02-14
product_list_20_20190215.csv -> Apple_2019-02-15
product_list_137_20190213.csv -> Samsung_2019-02-13
product_list_137_20190214.csv -> Samsung_2019-02-14
product_list_137_20190215.csv -> Samsung_2019-02-15

It should be very simple to do but after 2 days I still can't figure out how to do this in a single click...
rome1349
 
Posts: 1
Joined: Fri Feb 15, 2019 5:25 pm

Re: Rename with Pattern

Postby Emerkamp » Sun Feb 17, 2019 1:29 pm

Hi,

Try these codes. You'll have to run it as many time as you need for your #'s 20-137. just change 20 in match section and apple in replace.
RegEx (1)
Code: Select all
Match
(.*)_(20)_(\d\d\d\d)(\d\d)(\d\d)
Replace
\1_Apple_\3-\4-\5

and for 137
Code: Select all
Match
(.*)_(137)_(\d\d\d\d)(\d\d)(\d\d)
Replace
\1_Samsung_\3-\4-\5
Emerkamp
 
Posts: 140
Joined: Sat Aug 23, 2014 2:35 pm

Re: Rename with Pattern

Postby therube » Sun Feb 17, 2019 4:28 pm

I'm thinking the OP does not want the \1_ part in there.
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Rename with Pattern

Postby therube » Sun Feb 17, 2019 4:35 pm

I'd suspect you could set up a JavaScript translation table to be able to handle all the rename conditions at once?
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm


Return to BRU Support