How to keep just a 4 digit or 5 digit number

A swapping-ground for Regular Expression syntax

How to keep just a 4 digit or 5 digit number

Postby topdog » Thu Mar 05, 2015 1:24 am

I am having trouble on finding a way just to keep a 4 digit or 5 digit number.

My products have a 4 or 5 digit sku and a description as a file name. I am wanting the file name to be just the sku number. Unfortunately when the person created the files they didnt keep a uniform way of writing the name, so some time sku is first other times its at the end. I know if there is a 4 digit or 5 digit number it will be the sku

ZL02.5largedish3344.pdf - 3344.pdf
zl02.44567largeplate.pdf - 44567.pdf

Thanks to anyone who can help
topdog
 
Posts: 1
Joined: Thu Mar 05, 2015 1:16 am

Re: How to keep just a 4 digit or 5 digit number

Postby bitmonger » Thu Apr 02, 2015 1:22 am

Assuming there is only one 4 or 5 digit contiguous number buried in the filename you could do it as follows:

Use the RegEx section of Bulk Rename
RegEx (1)
Match .*?(\d\d\d\d\d?).*
Replace \1

Using it on the filename samples you gave it worked fine.

Hope this helps,
Bit
bitmonger
 
Posts: 50
Joined: Sat Sep 22, 2007 5:05 am


Return to Regular Expressions