Skip to content

Instantly share code, notes, and snippets.

@queertypes
Last active November 20, 2015 23:07
Show Gist options
  • Save queertypes/a7a35ed921a61f17b553 to your computer and use it in GitHub Desktop.
Save queertypes/a7a35ed921a61f17b553 to your computer and use it in GitHub Desktop.
Bash: Music Info via Mediainfo
#!/bin/bash
function get {
local srcfile="$1"
local field="$2"
mediainfo "$srcfile" | grep "$field" | head -n 1 | cut -d: -f 2 | xargs
}
title=$(get "$1" 'Track name ')
album=$(get "$1" 'Album')
artist=$(get "$1" 'Performer')
duration=$(get "$1" 'Duration')
if [ -n "$title" ]
then echo "$artist($album): $title - $duration"
else basename "$1"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment