Advertisement
Guest User

Current version of bash script

a guest
Jan 8th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.07 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # DESCRIPTION:
  4. # Very simple script to read the contents of the working
  5. # directory and encode all .avi files to .m4v for adding to
  6. # iTunes, copies to iTunes watched folder, then then deletes
  7. # the input file and the original output file.
  8. #
  9. # USES:
  10. # * HandBrakeCLI to encode the files
  11. # * Rsync to copy encoded files to their final destination
  12. #   so that progress can be tracked.
  13. #
  14. # TODO:
  15. # * Find a way to make HandBrakeCLI run silently
  16. #
  17.  
  18. output_destination="PATH/TO/SHARE"
  19.  
  20. for input in *.avi; do
  21.     output=$(echo $input|sed "s/.avi/.m4v/g")
  22.     HandBrakeCLI -i "$input" -o "$output" --preset="AppleTV 2"
  23.     if $? = 0
  24.     then
  25.         rsync -az --progress "$output" "$output_destination"
  26.         rm "$input"
  27.         rm "$output"
  28.         echo "[$(date +"%D %H:%M:%S")]
  29.    Source File: $input
  30.    Output file: $output
  31.    Encode successful
  32. " >> ~/Dropbox/Logs/logfile.txt
  33.     else
  34.         echo "[$(date +"%D %H:%M:%S")]
  35.    Source File: $input
  36.    Output file: $output
  37.    Encode failed
  38. " >> ~/Dropbox/Logs/logfile.txt
  39.     fi
  40. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement