Reputation: 63
I have some files in a folder like:
- Happysong.m4a.mp3
- Sad song ft. H.E.R.m4a.mp3
I want to rename these to:
- Happysong.mp3
- Sad song ft. H.E.R.mp3
Here is my code for test.bat
file which is placed in the same folder:
for /f "delims=" %%a in ('dir /b /a-d *.m4a.mp3') do (
set "oldName=%%~a"
set "newName=%oldName:.m4a=%"
ren %%a "%newName%"
)
It returns The syntax of the command is incorrect.
I've tried:
for /f "delims=" %%a in ('dir /b /a-d *.m4a.mp3') do (
set "oldName=%%~a"
set "newName=%oldName:.m4a=%"
ren %%a %newName%
)
which returns ft. was unexpected at this time.
What am I doing wrong here?
Upvotes: 0
Views: 1253
Reputation: 38613
You could probably do it like this from cmd:
For %G In (*.m4a.mp3) Do @For %H In ("%~nG") Do @Ren "%G" "%~nH%~xG"
Or like this from a batch-file:
@For %%G In (*.m4a.mp3) Do @For %%H In ("%%~nG") Do @Ren "%%G" "%%~nH%%~xG"
Upvotes: 2