I have multiple mp3 file like this:
Track [number of track].mp3
eg. Track 1.mp3
- Track 11.mp3
I want to rename them to:
T00[number of track]
eg. T001.mp3
- T011.mp3
I have tried to rename 1-9 tracks with this:
ren "Track ?.mp3" "T00 ?.mp3"
but I got space in filename (T00 1.mp3
)
Update: I'm trying to write the code to remove space this is my code
@echo off
setlocal enabledelayedexpansion
for /r %%G in ("T00 ?.mp3") do (
pause
echo -----------------------In loop----------------------------
echo Working with "%%G"
pause
set str=%%G
echo str is = "%str%"
pause
set str=%str: =0% //replace " " with 0
echo 2str is = "%str%"
pause
ren "%%~G" "%str%"
)
Message I got is:
-----------------------In loop----------------------------
working with "C:\test\T00 1.mp3"
str = ""
2str = ""
A duplicate file name exists, or the file
cannot be found.
.
.
.
I don't know what I wrong this is my fist time I using Batch Script
help setlocal
(orsetlocal /?
) and try to understand whatsetlocal enabledelayedexpansion
means. Then figure out whether it makes sense to use!str!
instead of%str%
. A more general bit of advice is that you shouldn’t let a script do anything until you have the logic debugged, so you know it’s going to do the right thing. For example, replaceren …
withecho ren …
.