Last active
November 20, 2015 23:07
-
-
Save queertypes/a7a35ed921a61f17b553 to your computer and use it in GitHub Desktop.
Bash: Music Info via Mediainfo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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