Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed loop terminating after first run. I will enver understand bash.…
…..I'm not sure it's meant to be understood...
  • Loading branch information
petersondrew committed Mar 29, 2012
1 parent f25f63f commit a392f5d
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions compress-several.sh
Expand Up @@ -4,7 +4,7 @@
usage(){
cat << EOF
usage: $0 options directory
This script compresses large movies with handbrake.sh
OPTIONS:
Expand Down Expand Up @@ -34,7 +34,7 @@ do
esac
done

shift $(($OPTIND - 1))
shift $(($OPTIND - 1))

DIRECTORY=$@
if [ -z "$DIRECTORY" ]; then
Expand All @@ -50,15 +50,23 @@ fi
FILES=$(find $DIRECTORY -type f -print0 | xargs -0 du -s | sort -nr | head -n $NUMBER | cut -f2)

compress(){
oIFS="$IFS"
IFS="
"
_files="$@"

if [ $DRYRUN = true ]; then
echo "$@" | while read file ; do
printf "File: %s\n" "$file"
for f in ${_files[*]}; do
printf "File: %s\n" "$f"
done
else
echo "$@" | while read file ; do
handbrake.sh "$file"
#echo "$@" | while read file ; do
for f in ${_files[*]}; do
handbrake.sh "$f"
done
fi

IFS=oIFS
}

compress "$FILES"

0 comments on commit a392f5d

Please sign in to comment.