- The resulting filename might be truncated at the troublesome character:
"Having My Cake & Yeeting It Too.flac" becomes
"Having My Cake "
Or in some circumstances extra characters from the batch script appear after the file extension:
"Troublesome Filename.mp3}"
I finally said enough is enough, and decided to figure this out once and for all. The best method I've found is to use a temporary filename and rename it after VLC is done converting. So here's the batch script I use to convert FLAC to MP3, which will also copy the FLAC tags to the MP3's ID3 tags if ffmpeg is installed:
Code: Select all
REM ---- Loop for each file ----
FOR %%A IN (%*) DO (CALL :SUB_VLC %%A)
REM *** In the event of errors, remove below REM to keep the console window open after processing:
REM PAUSE
GOTO :eof
:SUB_VLC
REM Note: _TEMP_A.mp3 will be overwritten by VLC if it exists
REM ---- Convert file to MP3 with VLC at 192kbps ----
REM *** Update path to VLC.exe if needed, and change 192 to 320 if desired
"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" -I dummy %1 --sout=#transcode{acodec=mp3,ab=192,vcodec=dummy}:standard{access=file,mux=raw,dst="_TEMP_A.mp3"} vlc://quit
REM ---- Copy FLAC tags to MP3 ID3 tags ----
REM *** ffmpeg must be installed. If it doesn't run from this script, it probably isn't "on the PATH". Either you will need to replace "ffmpeg" with the path to ffmpeg.exe (use quotes around the path if it contains spaces) *OR* add ffmpeg to the PATH System Variable.
ffmpeg -y -i %1 -map_metadata 0 -id3v2_version 3 "%~dp1_TEMP_A.mp3"
REM ---- Rename file ----
SET _outfile="%~n1.mp3"
REN "%~dp1_TEMP_A.mp3" %_outfile%
GOTO :eof
REM Some code ideas borrowed from VL22
I hope this will be helpful!
Michael
PS If you have ffmpeg installed, you could just leave VLC out entirely, and no need to worry about those pesky symbols:
Code: Select all
FOR %%A IN (%*) DO (CALL :SUB_MP3 %%A)
REM *** In the event of errors, remove below REM to keep the console window open after processing:
REM PAUSE
GOTO :eof
:SUB_MP3
SET _outfile="%~n1.mp3"
REM ---- Convert file to MP3 at 192kbps, keeps FLAC metadata ----
REM *** Change 192 to 320 if desired
ffmpeg -i %1 -ab 192k -map_metadata 0 -id3v2_version 3 %_outfile%
GOTO :eof