Append to start of filename

Solution 1:

There are three problems with your batch file:

  • In batch files, you have to use %%a instead of %a.

  • %%a will hold the full path, not just the filename.

  • The rename will fail if there are spaces in the filename.

In general, I'd also recommend leaving echo on while troubleshooting.

Try this instead:

cd /d c:\folder
for %%a in (*.mp3) do ren "%%a" "[Replay]%%a"

If that renames the files twice, for is reading the directory entries as it goes. As a workaround, you can save the list in a temporary file:

cd /d c:\folder
dir /b *.mp3 > temp
for /f "delims=" %%a in (temp) do ren "%%a" "[Replay]%%a"
del temp