1 (edited by Stefan 2007-06-03 13:43:54)

Topic: I want to delete beginning numbers

Q:   I have many MP3 files with leading track numbers like:

01-Artist1-Song.mp3
002 - Artist 2 - Song 4.mp3
3 Artist Song.mp3




A:    Because you have used a few different syntax how you add the track numbers .... I would use the power of regular expressions:

EXAMPLE:         
01-Artist1-Song.mp3
002 - Artist 2 - Song 4.mp3
3 Artist Song.mp3


EXPRESSION:    %f(s/(\d+)\s*-*\s*(.+)/$2/)

RESULT:
artist1-song.mp3
artist 2 - song 4.mp3
artist song.mp3




EXPLANATION:
%f(s/(\d+)\s*-*\s*(.+)/$2/)   ==>   %f( s/   (\d+)  \s*  -*  \s*  (.+)   /$2/   )

%f         is the hole file name
(s///)     is the frame of an reg ex  search and replace
so....

(s/         is the start of the reg ex
(...)        is an group. We can refer back to what we have found in this group
(\d+)      \d  means find an digit, .... + means find one or more of this, (...)  means group what we have found, this is our back reference No. 1
\s*         \s  means find an blank/space,.... * means find none or more
-*           -   means  find an dash -,.... * means find none or more
\s*         \s  means find an blank/space,.... * means find none or more
(.+)       . means find any char or sign,...+ means find one or more of this, (...)  means group what we have found, this is our back reference No. 2
/            / means to end the reg ex search and start witht the replacement
$2         $2  means give back what we have found in our second group
/)          /) means this is the end of our journey





OK, a little reg ex explanation:
* means find none or more  ==> means the RegEx match (is true) if the character  is found... or not.
Example:
1-A-S
1 A-S
RegEx: \d-*(.+)  find both because we look for an digit followed by an dash or no dash.


+ means find one or more ==> means the RegEx match (is true) if at least one character is found
Example:
1-A-S
1 A-S
RegEx: \d-+(.+)  find the first only because we must find at least one occurrence




Press the F1-key while you are in Siren to read more about.
Enjoy Siren,  No installation needed, unzip and run. Siren stores it settings into an ini file.
------------------------------------------------------------------------------------------------------------

                                             Siren is a freeware file renaming program
                                               - portable, highly flexible, powerfully -
                                          If it's looking tricky it's easy to rename with Siren.
                                          http://www.scarabee-software.net/en/siren.html

2

Re: I want to delete beginning numbers

Beautiful!

Re: I want to delete beginning numbers

Thanks for the feedback. It's nice to see this community lives. big_smile

Re: I want to delete beginning numbers

Works with Siren 3.0 too.


Only since the regular expression engine has changed to wxwidgets
we have to use the \n syntax instead of $n for backreferencing:



Instead $1, $2, $3,...

EXPRESSION:    %f(s/(\d+)\s*-*\s*(.+)/$2/)
---------------------------------------^


use \1, \2, \3,...

EXPRESSION:    %f(s/(\d+)\s*-*\s*(.+)/\2/)
----------------------------------------^



You can find details about the regular expression syntax in the wxWidgets online documentation
(http://docs.wxwidgets.org/trunk/overview_resyntax.html).
(Siren uses the ARE flavour)