Subject: Re: [Name Mangler Talk] swapping part of a name with another part

From: Rob Griffiths <[email-masked]>
Date: Tue, 13 Sep 2016 09:54:13 -0700

On Sep 12, 2016, at 11:22 PM, George Miller <[email-masked]> wrote:

> I have a lot of strangely named files that I need to swap parts of the name with another part of the name.
> they are named like this: W-2.wav, then W-3.wav and up to W-34.wav.
> I want to swap the numbers from the middle to the beginning and have the letter in the middle where the number was. 
> I tried the script that was posted in another thread but could not get it to work, 
> maybe I did not understand it correctly?=

Rearranging filenames is usually unique to each set of filenames, given how regular expressions (the tool we use to rearrange them) work. For you, the following should do the trick.

Find and Replace, find set to: (.*)-(.*)

Make sure both "Query is a regular expression" and "Ignore case" are checked.

Replace set to: $2-$1

That will change, for example, "W-17.wav" into "17-W.wav." Other things are possible, of course, but I think this is what you were asking for? The screenshot below shows the before/after.

How this works: The parentheses are used to make variables of subsets of text; the first set of () become $1, the next $2, etc. The first parens, (.*), say "find everything." But that's followed by a non-parenthesesed hyphen, which stops the find, so we wind up with everything up to the hyphen in $1. The next set of parens finds everything after the hyphen, which gets saved as $2. Then the replace just reverses the order.

regards,
-rob.

---

From: George Miller <[email-masked]>
Date: Mon, 12 Sep 2016 23:22:04 -0700 (PDT)

I have a lot of strangely named files that I need to swap parts of the name 
with another part of the name.
they are named like this: W-2.wav, then W-3.wav and up to W-34.wav.
I want to swap the numbers from the middle to the beginning and have the 
letter in the middle where the number was. 
I tried the script that was posted in another thread but could not get it 
to work, 
maybe I did not understand it correctly?
thanks for any help
George Miller