Created
May 21, 2026 04:51
-
-
Save anytizer/7a4f9161c5d01cfc323fd81d07fd5b44 to your computer and use it in GitHub Desktop.
Embed a cover art image to a .mp3 file using ffmpeg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| setlocal enabledelayedexpansion | |
| REM :: Create an output directory so we don't overwrite original files | |
| mkdir "output" 2>nul | |
| :: Loop through all .mp3 files in the current directory | |
| for %%F in (*.mp3) do ( | |
| set "filename=%%~nF" | |
| :: Check if a corresponding .jpg exists | |
| if exist "!filename!.jpg" ( | |
| echo Processing: "!filename!.mp3" with "!filename!.jpg" | |
| :: Run FFmpeg to embed the cover art | |
| ffmpeg -y -i "%%F" -i "!filename!.jpg" -c copy -map 0:a -map 1:v -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" "output\%%F" | |
| ) else ( | |
| echo Warning: No matching .jpg found for "%%F" | |
| ) | |
| ) | |
| echo Done! Check the 'output' folder. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment