Subject: Re: [Name Mangler Talk] mid()-like function in Name Mangler

From: Rob Griffiths <[email-masked]>
Date: Tue, 21 Jul 2015 08:55:04 -0700

On Jul 20, 2015, at 11:21 PM, Ola Holmstrom <[email-masked]> wrote:

> Is there a function that extracts part of a string, say 4 characters starting at position 14, and is it then possible to place that part at the beginning of the new filename, possibly using [concatenate]?

As of now, the only way to do that is via regular expressions.

> I'm pretty sure I can do it using RegEx, but EVERY time I need to use RegEx I need to re-learn it...  
> Note that the "filename" part of the name always has the same number of characters, so using a position within the text would be sufficient, rather than searching for a pattern (e.g. space followed by a number) within the string.  

The beauty of Name Mangler is that you can write it once then save it as a preset for easy reuse without having to remember it :). And that Name Mangler supports exporting configurations, which is what I did to create the attached configuration that should rename the files as you wish.  Unzip, then double-click, and it should open in Name Mangler, if you're using version 3. (Please please test on a copy, or have a good backup!)

If you're not on version 3, here's the regex...

Find: (.*)\ ([0-9][0-9])([0-9][0-9])([0-9][0-9][0-9][0-9])
Replace: $4-$3-$2 $1

The Find could probably be written in simpler form by those better at regex than I, but it works. Basically it grabs the filename and saves it in $1 (that's what the parentheses do, save the values into variables). Then it grabs and discards the space, and then it saves each of the date segments into its own variable. The Replace bit then just recalls the variables in a different order, and inserts the hyphens.

A future version of Name Mangler may include a more generic way of dealing with blocks of text; it's on our "to do" list for useful things to add.

regards,
-rob.

regards,
-rob.

-----------

---

From: Ola Holmstrom <[email-masked]>
Date: Mon, 20 Jul 2015 23:21:27 -0700 (PDT)

Hi!

I need to rename files that have a format of "filename DDMMYYYY.pdf" to 
"YYYY-MM-DD filename.pdf".

Is there a function that extracts part of a string, say 4 characters 
starting at position 14, and is it then possible to place that part at the 
beginning of the new filename, possibly using [concatenate]?

I'm pretty sure I can do it using RegEx, but EVERY time I need to use RegEx 
I need to re-learn it...  
Note that the "filename" part of the name always has the same number of 
characters, so using a position within the text would be sufficient, rather 
than searching for a pattern (e.g. space followed by a number) within the 
string.  

Cheers

Ola