Skip to content

Instantly share code, notes, and snippets.

@ldante86
Created November 7, 2016 19:45
Show Gist options
  • Save ldante86/2416471986d52205c288314d3ec29a36 to your computer and use it in GitHub Desktop.
Save ldante86/2416471986d52205c288314d3ec29a36 to your computer and use it in GitHub Desktop.
Get running length of media files
#!/bin/bash -
which mediainfo >/dev/null || {
echo mediainfo is not installed
exit 1
}
[ $# -eq 0 ] && set -- *
for i
do
case "$i" in
*.[Mm]*|*.[Aa][Vv][Ii]|*.ogg|*.[Ff][Ll]*|*.ape|*.[Ww][Aa][Vv])
if [ -f "$1" ]; then
echo -n "$1 -------- "
/usr/bin/mediainfo "$1" |
grep Duration |
awk -F: '{ print $2 }' |
head -n 1 |
sed 's/^ *//'
fi ;;
esac
shift
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment