RegEx not working?

A swapping-ground for Regular Expression syntax

RegEx not working?

Postby rfcomm2k » Fri Dec 26, 2014 4:41 pm

So maybe I do not understand the RegEx syntax. I read the help, I went to the more detailed working example, and I just cannot seem to make it do what I want done.

I have a collection of .mp3 files in which some have track numbers embedded as the first characters of the filename. For example:
'02 The Great Pretender.mp3'.
Also there can be found others with this syntax:
'14 - Angel Band 3 times.mp3'.

I filled in the RegEx (1) match field with '01 ' (left out the quote marks) and left the Replace field blank, but none of the selected files changed color in the select window. I then moved to the Repl (3) section and repeated this. Now all files that had a '01 ' at the beginning turned green, so I knew I was on the right track.

However, doing it this way would be tedious at best, because I have 29,648 files that have track numbers embedded, tracks running from 1 thru 31.

Is there something I am missing, or is this just how I need to do it?
rfcomm2k
 
Posts: 1
Joined: Fri Dec 26, 2014 4:25 pm

Re: RegEx not working?

Postby TheRegExpMaster » Fri Dec 26, 2014 7:31 pm

rfcomm2k wrote:I filled in the RegEx (1) match field with '01 ' (left out the quote marks) and left the Replace field blank, but none of the selected files changed color in the select window.

The files didn't turn green but the string was matched. You will see it by filling the "Replace" field under "Match".

If you want to remove the numbers at the beginning of the file and the dashes, try this ;)

REGEX(1)
MATCH :
Code: Select all
^\d+[\s-]*\b(.+)
REPLACE :
Code: Select all
\1
"01 hello.mp3" will be renamed "hello.mp3".
"01 - hello.mp3" will be renamed "hello.mp3".
"01- hello.mp3" will be renamed "hello.mp3".
"01 -hello.mp3" will be renamed "hello.mp3".
"01-hello.mp3" will be renamed "hello.mp3".
"01.mp3" will be left as "01.mp3".
TheRegExpMaster
 
Posts: 25
Joined: Wed Nov 05, 2014 8:45 pm


Return to Regular Expressions


cron