I am writing a batch file to convert music files and have saved a file name in a variable. A couple of examples would be:
David Bowie - Space Oddity.mp3
Or maybe
David Bowie - Greatest Hits - Space Oddity.mp3
I'd like to edit the variable so it just contains the track name Space Oddity. So I need to search backwards from the end until I reach the first occurrence of {Hyphen}{Space}, and discard everything that comes before it, (since the variable might contain more than one hyphen).
Please could you suggest some batch code to achieve this?
set "mp3_name=%mp3_name:*- =%"and you will have to do this more than once depending on how many instances of ` - ` you want to remove. Also, for renaming music files, I'd recommend existing software like FileBot or TagScanner.