Renaming multiple files within folder(s)
Moderator: DosItHelp
Renaming multiple files within folder(s)
In my music directory, I have several folders, ie Beach Music, Country, Classic Rock, etc. Within each of these folders are music files (mp3) with the current format as the filename:
group - songtitle.mp3 ie Beach Boys - California Girls.mp3
(the file extension .mp3 does not appear under the name column of the directory)
I would like to go through each mp3 file I have that has this name format and remove everything prior to the actual songtitle so that "Beach Boys - California Girls" would be renamed to "California Girls".
How can I do this in a batch file? I use Windows 7.
Thanks
group - songtitle.mp3 ie Beach Boys - California Girls.mp3
(the file extension .mp3 does not appear under the name column of the directory)
I would like to go through each mp3 file I have that has this name format and remove everything prior to the actual songtitle so that "Beach Boys - California Girls" would be renamed to "California Girls".
How can I do this in a batch file? I use Windows 7.
Thanks
Re: Renaming multiple files within folder(s)
?why not _http://www.mp3tag.de/en/
Re: Renaming multiple files within folder(s)
Was not aware of that. However, I like programming and learning it. Just figure a simple batch file would accomplish what I need to do.
Re: Renaming multiple files within folder(s)
Is it always a combination of space|hyphen|space that separates the group from the song title? Can you make sure that this combination exists only once in a file name?
Regards
aGerman
Regards
aGerman
Re: Renaming multiple files within folder(s)
Yes, everyone currently has the format for the filename using " = ", ie space hypen space.
The name of the artist or group is first with the song title following. They are separated with " - ", examples
Beach Boys - California Girls
Beach Boys - Barbara Ann
Chairman of the Board - Be Young, Be Foolish
I want to remove everything prior to the song title, including the space just before the song title.
The name of the artist or group is first with the song title following. They are separated with " - ", examples
Beach Boys - California Girls
Beach Boys - Barbara Ann
Chairman of the Board - Be Young, Be Foolish
I want to remove everything prior to the song title, including the space just before the song title.
Re: Renaming multiple files within folder(s)
run in root directory
no hyphen in dir's names allowed
Code: Select all
for /f "tokens=1,2* delims=-" %%a in ('dir /a-d/b/s "* - *.mp3"') do (
set "name=%%b"
call ren "%%~dpna -%%b" "%%name:~1%%"
)
no hyphen in dir's names allowed
Re: Renaming multiple files within folder(s)
Similar:
hyphens in folder names allowed
Regards
aGerman
Code: Select all
@echo off &setlocal
for /f "delims=" %%a in ('dir /a-d /b /s "* - *.mp3"') do (
set "oldname=%%~nxa"
setlocal enabledelayedexpansion
for /f "tokens=1* delims=?" %%b in ("!oldname: - =?!") do (
ren "%%a" "%%c"
)
endlocal
)
pause
hyphens in folder names allowed
Regards
aGerman
Re: Renaming multiple files within folder(s)
trouble with exclamation marks in namesaGerman wrote:setlocal enabledelayedexpansion
ex. "After School - Bang!.mp3"
Re: Renaming multiple files within folder(s)
Haha you won, !k.
Lets write a code with the best of both.
Regards
aGerman
Lets write a code with the best of both.
Code: Select all
@echo off &setlocal
for /f "delims=" %%a in ('dir /a-d /b /s "* - *.mp3"') do (
for /f "tokens=1* delims=-" %%b in ("%%~nxa") do (
set "name=%%c"
call ren "%%a" "%%name:~1%%"
)
)
Regards
aGerman
Re: Renaming multiple files within folder(s)
private message wrote:Does the batch file need to be in the directory of the files being renamed. If not, where do I indicate the path?
for /f "delims=" %%a in ('dir /a-d /b /s "D:\My Music\* - *.mp3"') do (
Re: Renaming multiple files within folder(s)
Thanks for the code. I tried Expert's first and it works great. Did not try aGerman's. Thank you both for your time and contribution to my question.