I want to remove a part of the file name per the below example:
file name is "anita baker - rapture.mp3" or "john legend - ordinary people.mp3"
I want a script to remove everything up to and including the "-" in all file names so all the file names just have a space before the artist name (inserting track number with another macro).
I can't find out to do this because there are no certain number of characters. I could do replace for each artist, but I have to type in each artist's name. Is there an easier way?
How it works
I've attached a screen shot of the regexp. On the top half you'll see "^" which anchors it to the very start of the text and "()" with stuff inbetween those. Basically they capture whatevers inside them. So the return is $2 which in-cases what you need. But for example you COULD say $1 which would return "anita baker - " instead of "rapture.mp3"
I take it the second part is the song title? If you already have the title in the TITLE field, then all you need to do is rename the file using that field.
Action type:Format value Field:_FILENAME Format string:%title%
To include the track number, use
Action type:Format value Field:_FILENAME Format string:$num(%track%,2) %title%
Be aware of, that a file name, which starts with a space character, might be not allowed by the underlying filesystem.
For example, Windows Explorer automatically removes leading space characters from the filename, when trying to rename a file to get leading space characters.
Action: Format value
Field: _FILENAME
Formatstring: %TRACK%$right(%_filename%,$strstr($reverse(%_filename%),'- '))
From:
TRACK = 1
FILENAME = john legend - ordinary people
To:
FILENAME = 1 - ordinary people
... or ...
Action: Format value
Field: _FILENAME
Formatstring: %TRACK%$right(%_filename%,$strstr($reverse(%_filename%),' - '))
From:
TRACK = 1
FILENAME = john legend - ordinary people
To:
FILENAME = 1 ordinary people