YaK:: Discussion #916 Message : 2011-09-04 07.28.33 strick [Changes]   [Calendar]   [Search]   [Index]   [PhotoTags]   
  [Back to discussion: The Yak tries Linux Webcam Video]  
[mega_changes]
[photos]

Discussion #916 Message: 2011-09-04 07.28.33 strick

$ cat /usr/local/bin/a

#!/bin/bash
cd $HOME/Downloads

DIR="$1"
mkdir -p "$DIR"

case $# in
1)
  ls *.mp4 *.flv *.mp4.crdownload *.flv.crdownload *.mp4.part *.flv.part 2>/dev/null |
  while read f ; do
    test -f "$f" && test -s "$f" || continue
    case "$f" in
      *.crdownload )
        g=$(basename "$f" .crdownload)
        test -f ",$g," && continue
        bash "$0" "$DIR" "$f" &
        echo ::::: $! ::::: "$DIR" ::::: "$f" >&2
	;;
      *.part )
        g=$(basename "$f" .part)
        test -f ",$g," && continue
        bash "$0" "$DIR" "$f" &
        echo ::::: $! ::::: "$DIR" ::::: "$f" >&2
	;;
      * )
        mv -v "$f" "$DIR"
	;;
    esac
  done
  ;;
2)
  f="$2"
  g=$(basename "$f" .crdownload)
  g=$(basename "$g" .part)
  ln "$f" ",$g,"
  while true ; do
    if test -f "$g" && test -s "$g"; then
        echo "   $$ @@@" >&2
        mv -v "$g" "$DIR"
	rm ",$g,"
	break
    fi
    sleep 1
  done
  ;;
*)
  echo WTF: $* >&2
  exit 13
  ;;
esac


(unless otherwise marked) Copyright 2002-2014 YakPeople. All rights reserved.
(last modified 2011-09-04)       [Login]
(No back references.)