(Inspired by this post) @echo off setlocal EnableDelayedExpansion rem Iterate over each line outputted by `beet ls -p` for /f "tokens=*" f" echo "!f!" rem Get lyrics using `beet lyrics` for /f "delims=" L" ) rem Set the name for the .lrc file set "lrc=!f:~0,-4!.lrc" rem Check if lyrics are found and write to .lrc file if defined lyrics ( echo "-> !lrc!" echo "!lyrics!" > "!lrc!" ) else ( echo No lyrics found. ) ) endlocal