Skip to content

Instantly share code, notes, and snippets.

@rdela
Forked from lisamelton/batch.sh
Created July 3, 2014 02:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdela/09631a311b98bd1c1630 to your computer and use it in GitHub Desktop.
Save rdela/09631a311b98bd1c1630 to your computer and use it in GitHub Desktop.
#!/bin/bash
# batch.sh
#
# Copyright (c) 2013 Don Melton
#
# This version published on June 8, 2013.
#
# Batch control for the "encode.sh" script.
#
# Input is read from a file named "queue.txt" which must be in the same
# directory as this script. The queue format is extremely simple. It's just a
# carriage return-delimited list of full paths to media files. The paths can
# contain spaces and shouldn't be quoted.
#
# The path is first deleted from the "queue.txt" file and then passed as an
# argument to the "encode.sh" script. To pause encoding after the "encode.sh"
# script returns, simply insert a blank line at the top of the "queue.txt"
# file.
#
# The "encode.sh" script must also be in the same directory as this script.
#
# Usage:
#
# ./batch.sh
#
work="$(cd "$(dirname "$0")" && pwd)"
queue="$work/queue.txt"
input="$(sed -n 1p "$queue")"
while [ "$input" ]; do
sed -i '' 1d "$queue" || exit 1
"$work/encode.sh" "$input"
input="$(sed -n 1p "$queue")"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment