Skip to content

Instantly share code, notes, and snippets.

@rogersguedes
Created July 5, 2019 16:20
Show Gist options
  • Save rogersguedes/4538f12439c6fc71e290b58d7cfa7c0b to your computer and use it in GitHub Desktop.
Save rogersguedes/4538f12439c6fc71e290b58d7cfa7c0b to your computer and use it in GitHub Desktop.
This script parses file info generated by ffmpeg and, if the first stream is an audio stream, moves to file to from $1 to $2
#!/bin/bash
# This script parses file info generated by ffmpeg and, if the first stream is an audio stream, moves to file to from
# $1 to $2
# https://www.computerhope.com/unix/bash/read.htm
find $1 -maxdepth 1 -type f -print0 |
while IFS= read -r -d '' line
do
ffmpeg -i "${line}" 2>&1 | grep --color=always "Stream #0:0[()a-z]*: Audio" > /dev/null
if [ $? -eq 0 ]; then
echo ${line}
mv "${line}" $2
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment