#!/bin/sh # file identification script # # manual usage: # mpv_identify.sh foo.mkv # # sh/dash/ksh/bash usage: # . mpv_identify.sh FOO_ foo.mkv # will fill properties into variables like FOO_length # # zsh usage: # mpv_identify() { emulate -L sh; . mpv_identify.sh "$@"; } # mpv_identify FOO_ foo.mkv # will fill properties into variables like FOO_length # # When multiple files were specified, their info will be put into FOO_* for the # first file, FOO_1_* for the second file, FOO_2_* for the third file, etc. __midentify__main() { case "$0" in mpv_identify.sh|*/mpv_identify.sh) # we are NOT being sourced [ -n "$1" ] && set -- '' "$@" ;; esac if [ "$#" -lt 2 ]; then cat >&2 <&2 "Got X-MIDENTIFY: without X-MIDENTIFY-START:" elif [ -n "$value" ]; then eval "$prefix$key"='"$value"' fi else if [ -n "$value" ]; then printf '%s=%s\n' "$key" "$value" fi fi ;; esac done <