Windows Batch File Conversion with Retained Audio Metadata using FFmpeg Error

1

I'm fairly new to using this program, and really programming of any kind, but after tooling around on the internet (a lot of this site actually), I managed to come up with this.

@ECHO OFF

FOR %%AA IN (*.flac) DO (
echo Converting: %%AA
ffmpeg -i "%%AA" -q:a 0 -map_metadata 0 "%%~nf.mp3"
)

echo Finished

PAUSE

The problem I'm running into is that when I run the program I get the error "At least one output file must be specified". When I remove the -map_metadata 0 command, the program works fine, but no metadata is saved in the mp3 file. Does anyone know what's going wrong with this program, or what I can chnage to fix it?

EDIT: Now correctly displays my code.

AeonCenturion

Posted 2017-03-14T23:08:23.560

Reputation: 11

if you add echo in front of the ffmpeg what do you see? – Stephen Rauch – 2017-03-14T23:21:59.430

Converting: %AA ffmpeg -i "%AA" -q:a 0 -map_metadata 0 "test.mp3" – AeonCenturion – 2017-03-14T23:25:37.303

This seems to be an ffmpeg error so double check your syntax and confirm you can run with a single file first... report back your results.. – Pimp Juice IT – 2017-03-15T01:02:34.073

Answers

1

I think you need to replace the %%AA with %%f:

Code:

@echo off
FOR %%f IN (*.flac) DO (
echo Converting: %%f
ffmpeg -i "%%f" -q:a 0 -map_metadata 0 "%%~nf.mp3"
)

Stephen Rauch

Posted 2017-03-14T23:08:23.560

Reputation: 2 455

I'm still getting the same error. I don't actually know why my code appeared like that in my post here, I originally had all of the lines as %%AA in my batch file. – AeonCenturion – 2017-03-14T23:44:30.237

redo the echo experiment and make sure the echo command line looks like what you expect it to. Also you should edit your post to look like reality. – Stephen Rauch – 2017-03-14T23:45:54.387

Converting: Test 1.flac ffmpeg -i "Test 1.flac" -q:a 0 -map_metadata 0 "Test 1.mp3" This is right as far as I can tell – AeonCenturion – 2017-03-14T23:52:19.473

If you cut and paste the second echo output to the command line, do you get the same result? – Stephen Rauch – 2017-03-14T23:57:40.990

Yes, I still get the same error. – AeonCenturion – 2017-03-15T00:02:18.393

So this appears to be a command line issue, not a batch issue. So at the command line, try it again with a file with no spaces in the name, it might be some sort of quoting issue. GL. – Stephen Rauch – 2017-03-15T00:40:16.753