ffmpeg/batch file: input format stays in output file name

3.4k views Asked by At

I created this batch file to put all aac files in one directory into an m4a container. The command works so far, but every new file generated has the format of the input file in the output files name.

For example: test(.aac) is in an m4a container but is NAMED test.aac(.m4a)

Here is the .bat file:

for /r %%X in (*.*) do (
    ffmpeg -i "%%X" "%%X.m4a"
)
pause

I'll be grateful for any easy solution, best regards and thanks to everyone

1

There are 1 answers

5
PA. On BEST ANSWER

you need to extract just the name without extension

for /r %%X in (*.aac) do (
    ffmpeg -i "%%X" "%%~dpnX.m4a"
)

see HELP FOR for an explanation of the %%~dpn syntax, in short

%%~X - expands %%X removing any surrounding quotes (")
%%~fX - expands %%X to a fully qualified path name
%%~dX - expands %%X to a drive letter only
%%~pX - expands %%X to a path only
%%~nX - expands %%X to a file name only

I have also changed a bit the FOR selection mask to iterate only over .aac files.