Delete zeros up to first whole number

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

Delete zeros up to first whole number

Postby Skijet09 » Fri Sep 25, 2015 4:28 pm

Hi, I have files that look like the below

12345_00000000987654321.pdf
12345_00000022233300000.pdf
12345_00000000000000321.pdf

I need to delete all the zeros after the underscore but before the first whole number (1-9) I cant use the from and to in the Remove F5 area because the first whole number isn't always in the same spot.

Help!
Skijet09
 
Posts: 1
Joined: Fri Sep 25, 2015 4:20 pm

Re: Delete zeros up to first whole number

Postby Stefan » Fri Sep 25, 2015 7:54 pm

FROM:
12345_00000000987654321.pdf
12345_00000022233300000.pdf
12345_00000000000000321.pdf

TO:
12345_987654321.pdf
12345_22233300000.pdf
12345_321.pdf


USE:

RegEx(1)
Match: (\d+_)0+(\d+)
Repla: \1\2


Explanation:
Match one-or-more digits     "\d+"     followed by an underscore "_" ---------> and store in capture group (1)
Match one-or-more zeros     "0+"      (works here greedy, to match all zeros)
Match one-or-more digits    "\d+"     ---------> and store in capture group (2)

Replace with what was captured in group 1 and 2:    "\1\2"

- - -

With using other tools one may have to use something like: (\d+_)0+([1-9]+)



HTH?
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to BRU Support