Could I get some help converting this batch script to an shell script? I don't know how to get the second part working, would I just pipe the first into the 2nd instead of having the brackets? (and changing the %%a stuff):

echo off
for %%a in ("*.aac") do (
  ffmpeg -i "%%a" -an -vcodec copy "%%~na.jpg"
  "ffmpeg.exe" -loop 1 -i  "%%~na.jpg" -i "%%a" -c:v libx264 -preset veryslow -tune stillimage -crf 18 -pix_fmt yuv420p -c:a aac -shortest -b:a 192k -shortest "%%~na.mp4" )
  • You should add details about what the script is supposed to do.
    – user1083716
    Jul 5, 2020 at 6:56

1 Answer 1


Not sure what is the purpose of the script but this solution should work:

for file in *.aac; do
    ffmpeg -i "$file" -an -vcodec copy "${file%aac}jpg"
    ffmpeg -loop 1 -i  "${file%aac}jpg" -i "$file" -c:v libx264 -preset veryslow -tune stillimage -crf 18 -pix_fmt yuv420p -c:a aac -shortest -b:a 192k -shortest "${file%aac}mp4"

I replaced:

  • %%a by the $file shell variable;
  • %%~na which is removing the file extension by ${file%aac};
  • ffmpeg.exe by the ffmpeg command.
  • Whoops! Thanks for correcting my mistake and good point with the portable parameter expansion.
    – user1083716
    Jul 5, 2020 at 11:46
  • No problem - upvoted :) Jul 5, 2020 at 11:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .