Subject: Re: [Name Mangler Talk] Removing spaces & #'s after

From: Rob Griffiths <[email-masked]>
Date: Tue, 21 Apr 2015 13:52:19 -0700

On Apr 21, 2015, at 10:01 AM, B VRooy <[email-masked]> wrote:

> 31294_9BYBDHAS806_Prod_1_Charcoal Plaid 48.tif
> 31294_9BYBDHAS806_Prod_2_Charcoal Plaid 4.tif
> 
> As you can see, sometimes the numbers are 1-3 digits long, and sometimes there aren't numbers.
> Is there a way to remove the numbers at the end, including the space? I cannot figure this out for the life of me.

You can do this using regular expressions, and probably in a number of ways. I'm not the greatest with regular expressions, but this seems to work for your demo filenames:

The Find bit is: (.*)\ [0-9].*
The Replace bit is: $1

How it works: In regular expressions, items in parentheses become variables you can use later; the first set becomes $1, the next $2, etc. So (.*) basically says "find everything (which is .*) and store it in $1 (because it's in parens)." But it stops finding when it sees a match for the next character, which is a space (delimited by a backslash -- \ ). So now we've got everything in the name, up to the first space, in $1.

After the space, I just look for a digit 0-9, followed by anything else -- note that my method would capture "1abce" as well as the numbers-only examples you provided. Neither the space nor the trailing digits are saved as variables, because we don't need them.

Then the replace bit just restores the variable we saved; make sure "keep extension intact" is checked, too.

NOTE: Please try with a COPY of your files, in case something fails!

And also note I'm sure there are better/other ways to do this; this is just what worked for my brain on my first look at your request :).

regards,
-rob.

---

From: B VRooy <[email-masked]>
Date: Tue, 21 Apr 2015 10:01:47 -0700 (PDT)

Hi all, I have a problem here. 
I'm trying to remove and numbers at the end of a file name, along with a 
space.
I've pasted a few filenames here as an example:

18270_501-0193_Prod_1_Denim 123.tif
18270_501-0193_Prod_2_Denim 156.tif
18280_PYB101M_Prod_1_BLACK 43.tif
18280_PYB101M_Prod_2_BLACK.tif
31294_9BYBDHAS806_Prod_1_Charcoal Plaid 48.tif
31294_9BYBDHAS806_Prod_2_Charcoal Plaid 4.tif

As you can see, sometimes the numbers are 1-3 digits long, and sometimes 
there aren't numbers.
Is there a way to remove the numbers at the end, including the space? I 
cannot figure this out for the life of me.

Thanks in advance!