Subject: Re: [Name Mangler Talk] Conditional File Naming

From: Carl Schneider <[email-masked]>
Date: Tue, 9 Jun 2020 09:36:30 -0700 (PDT)

Wow, thank you so much!!!   I will try this out. 

On Tuesday, June 9, 2020 at 9:30:24 AM UTC-7, Many Tricks wrote:
>
> On Jun 9, 2020, at 8:07 AM, Carl Schneider <[email-masked] 
> <javascript:>> wrote: 
>
> > For example, here are some original filenames: 
> > 
> > 13A13-101.mov 
> > 16B53-132.mov 
> > 27A21-201.mov 
> > 28A13-127.mov 
> > 50A13-321.mov 
> > 
> > And I would want the result to be: 
> > 
> > 101813A13-101.mov 
> > 132516B53-132.mov 
> > 201427A21-201.mov 
> > 127328A13-127.mov 
> > 321150A13-321.mov 
>
> You can, though this one is messier: 
>
>

---

From: Rob Griffiths <[email-masked]>
Date: Tue, 9 Jun 2020 09:30:17 -0700

The config file is attached, but basically, here's how it works:

The Advanced chunk encodes your key (hopefully I got it right - please double-check everything). The regular expresison (I'll just pick one, as they're all the same) works like this:

^50([A-Z]) - The carat means "find at the beginning," so we don't find those digits elsewhere. Then there's the digits, and then ([A-Z]) means "any A to Z character immediately following those digits." This is put in parentheses, so it's a variable we can use in the replace–this is necessary, because otherwise, previous commands will change future matches: The "50" file becomes "150," which now matches a generic "15" rule. But it doesn't match a "15 followed by a character" rule.

The replace side is just your replacement value, 1 in this example, followed by the original 50, and then we put back the character we saved in the variable.

The final step in the Advanced process is to concatenate the new name with the extension, as that's not automatic in Advanced mode.

The next step is the same as before, to copy the last three digits to the front.

regards;
-rob.

------

---

From: Carl Schneider <[email-masked]>
Date: Tue, 9 Jun 2020 08:07:03 -0700 (PDT)

I have one more question about this. What if I wanted to add one digit 
before the 3-digit prefix (copied from the last three digits), that was 
based on the original first two digits? I would want the following one 
digit to be added for the following original digits: 

50 1 

29 2

28 3

27 4

16 5

15 6

14 7

13 8

12 9 

13A13-101.mov 

16B53-132.mov 

27A21-201.mov 

28A13-127.mov 

50A13-321.mov 

101813A13-101.mov 

132516B53-132.mov 

201427A21-201.mov 

127328A13-127.mov 

321150A13-321.mov 

Again, thank you so much for your help!  

On Monday, June 8, 2020 at 8:32:39 AM UTC-7, Many Tricks wrote:
>
> On Jun 8, 2020, at 8:14 AM, Carl Schneider <[email-masked] 
> <javascript:>> wrote:
>
> Wow, thank you! One last related question that is hopefully easier. It is 
> possible to just copy the last three digits at the end of the filename and 
> repeat them at the beginning of the filename? 
>
>
> You mean, instead of the alpha characters? Sure, that'd be much easier 
> (see first attached screenshot). You just need a Find/Replace like this;
>
> Find: ^.*(\d{3})$
> Replace: $1-[Name]
>
> In the above, [Name] means "click the + sign in the Replace box, and 
> select Name from the list of metadata." You can change the replace part 
> however you like.
>
> If you don't want the repetition, it's quite easy to move the last three 
> to the front, too—see the second screenshot. To do that, you need this:
>
> Find: (^.*)-(\d{3})$
> Replace: $2-$1
>
> regards;
> -rob.
>
> ---------
>
>
>
>

---

From: Carl Schneider <[email-masked]>
Date: Mon, 8 Jun 2020 09:00:32 -0700 (PDT)

Thank you!!!

---

From: Rob Griffiths <[email-masked]>
Date: Mon, 8 Jun 2020 08:32:34 -0700

On Jun 8, 2020, at 8:14 AM, Carl Schneider <[email-masked]> wrote:

> Wow, thank you! One last related question that is hopefully easier. It is possible to just copy the last three digits at the end of the filename and repeat them at the beginning of the filename? 

You mean, instead of the alpha characters? Sure, that'd be much easier (see first attached screenshot). You just need a Find/Replace like this;

Find: ^.*(\d{3})$
Replace: $1-[Name]

In the above, [Name] means "click the + sign in the Replace box, and select Name from the list of metadata." You can change the replace part however you like.

If you don't want the repetition, it's quite easy to move the last three to the front, too—see the second screenshot. To do that, you need this:

Find: (^.*)-(\d{3})$
Replace: $2-$1

regards;
-rob.

---------

---

From: Carl Schneider <[email-masked]>
Date: Mon, 8 Jun 2020 08:14:06 -0700 (PDT)

On Monday, June 8, 2020 at 7:59:59 AM UTC-7, Many Tricks wrote:
>
> On Jun 7, 2020, at 9:33 PM, Carl Schneider <[email-masked] 
> <javascript:>> wrote: 
>
> > Yes, that is correct. Thanks for checking. 
>
> Peter found a solution—it's not very pretty, but it works: 
>
> "The request boils down to converting numbers (e.g., 101 => 27/AA), and we 
> can use Advanced Code's "letters" function to do that. Note that this isn't 
> a sequence in the traditional sense, because we increment by zero, which 
> has the same effect as starting a new sequence for each file. The only 
> thing we're interested in is the "from" parameter, which allows us to 
> reference the filename's last three digits and convert them to letters 
> while applying an offset that turns 101 into 27 by subtracting 74." 
>
> See the attached screenshot, and you can download and test (on a copy of 
> your files) the Name Mangler action. 
>
> regards; 
> -rob. 
>
>

---

From: Rob Griffiths <[email-masked]>
Date: Mon, 8 Jun 2020 07:59:56 -0700

"The request boils down to converting numbers (e.g., 101 => 27/AA), and we can use Advanced Code's "letters" function to do that. Note that this isn't a sequence in the traditional sense, because we increment by zero, which has the same effect as starting a new sequence for each file. The only thing we're interested in is the "from" parameter, which allows us to reference the filename's last three digits and convert them to letters while applying an offset that turns 101 into 27 by subtracting 74."

See the attached screenshot, and you can download and test (on a copy of your files) the Name Mangler action.

regards;
-rob.

---

From: Carl Schneider <[email-masked]>
Date: Sun, 7 Jun 2020 21:33:01 -0700 (PDT)

---

From: Rob Griffiths <[email-masked]>
Date: Sun, 7 Jun 2020 21:10:50 -0700

On Jun 7, 2020, at 2:14 PM, Carl Schneider <[email-masked]> wrote:

> Is it possible to do conditional file renaming, based on the last three digits of the current filename? 

You could use sequence numbers, but that would only work if there weren't any missing numbers in the sequence. If there are missing numbers, ie you have this...

27A13-101.mov 
27A13-102.mov 
27A13-104.mov 
27A13-106.mov 

...then that will fail, because #104 will get AC instead of AD, which is what you'd want it to be. There's no way I can think of do what you want in Name Mangler, but I'll double-check with Peter and let you know. You need this to work for some arbitrary number of files that may or may not be missing some of the numbers in sequence, right?

-rob.

---

From: Carl Schneider <[email-masked]>
Date: Sun, 7 Jun 2020 14:14:20 -0700 (PDT)

Is it possible to do conditional file renaming, based on the last three 
digits of the current filename? 

For example, I have the following file names: 

27A13-101.mov 

27A13-102.mov 

27A13-103.mov 

...

27A13-127.mov 

27A13-128.mov 

27A13-129.mov 

And I want to add a two letter prefix sequence, such as AA, AB, AC... AZ, 
BA, BB, BC, etc, based on the last three digits like this: 

AA27A13-101.mov 

AB27A13-102.mov 

AC27A13-103.mov 

...

BA27A13-127.mov 

BB27A13-128.mov 

BC27A13-129.mov 

So then all filenames ending with "101" would have "AA" added to the 
beginning. All filenames ending with "127" would have "BA" added to the 
beginning, etc. 

Thanks in advance for your help.