#!/bin/bash # Name: oggz-comments # Version: 0,1a # Author: VolodyA! V Anarhist # Year: 2010 # Licence: GPL 3.0 # this is an oggz-comment wrapper # the command line should be in the form # oggz-comments [-o output.ogg | --output output.ogg] [-d | --delete] [-a | -all] [-s serialno | --serialno serialno] [-c content-type | --content-type content-type] [-m metadata.txt | --metadata-file metadata.txt] input.ogg # or # oggz-comments -h|--help #if help if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then echo "oggz-commenta version 0,1a. written by VolodyA! V Anarhist" echo "The command line should look like this:" echo "oggz-comments [-o output.ogg | --output output.ogg] [-d | --delete] [-a | -all] [-s serialno | --serialno serialno] [-c content-type | --content-type content-type] [-m metadata.txt | --metadata-file metadata.txt] input.ogg" exit fi #go through all the command line a word at a time OUTPUT="" DELETE="" STREAMS="" METADATA="" INPUT="" STATE="" for COMMAND in "$@"; do if [ ${COMMAND:0:1} = "-" ]; then if [ "$COMMAND" = "-o" ] || [ "$COMMAND" = "--output" ]; then STATE="--output" elif [ "$COMMAND" = "-d" ] || [ "$COMMAND" = "--delete" ]; then DELETE="--delete" STATE="" elif [ "$COMMAND" = "-a" ] || [ "$COMMAND" = "--all" ]; then STREAMS="$STREAMS --all" elif [ "$COMMAND" = "-s" ] || [ "$COMMAND" = "--serialno" ]; then STATE="--serialno" elif [ "$COMMAND" = "-c" ] || [ "$COMMAND" = "--content-type" ]; then STATE="--content-type" elif [ "$COMMAND" = "-m" ] || [ "$COMMAND" = "--metadata-file" ]; then STATE="--metadata-file" else echo "Wrong command command '$COMMAND'" echo "Use oggz-comments --help for useage information." exit 1 fi elif [ -n "$STATE" ]; then # if the STATE is not zero-length if [ "$STATE" = "--output" ]; then OUTPUT="--output $1" elif [ "$STATE" = "--serialno" ]; then STREAMS="$STREAMS --serialno $1" elif [ "$STATE" = "--content-type" ]; then STREAMS="$STREAMS --content-type $1" elif [ "$STATE" = "--metadata-file" ]; then if [ ! -f "$1" ] || [ ! -r "$1" ]; then echo "File '$1' doesn't exist or is not readable" exit 2 fi while read LINE do METADATA="$METADATA \"$LINE\"" done < "$1" fi STATE="" else if [ ! -f "$1" ] || [ ! -r "$1" ]; then echo "File '$1' doesn't exist or is not readable" exit 2 fi INPUT="$1" fi shift done eval oggz-comment $OUTPUT $DELETE $STREAMS $INPUT $METADATA