folderFixup.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/bash
  2. # Parameters
  3. inFolder="`~/bin/video/mediaPath`/TV"
  4. # Command line
  5. if [ -n "${1}" ]; then
  6. inFolder="${1}"
  7. fi
  8. if [ ! -e "${inFolder}" ]; then
  9. echo "Usage: `basename "${0}"` input_folder" 1>&2
  10. exit 1
  11. fi
  12. # Bail if we're already running
  13. me="`basename "${0}"`"
  14. if [ `ps auwx | grep -v grep | grep "${me}" | wc -l` -gt 2 ]; then
  15. exit 0
  16. fi
  17. # Bail if the load is high
  18. if ! ~/bin/video/checkLoad.sh; then
  19. exit 0
  20. fi
  21. # Bail if the media share isn't available
  22. if ! ~/bin/video/isMediaMounted; then
  23. exit 0
  24. fi
  25. # Cache output
  26. tmp="`mktemp -t 'folderFixup.XXXXXXXX'`"
  27. # Re-wrap or recode as needed
  28. find "${inFolder}" -mindepth 1 -type d -exec ~/bin/video/folderToMKV.sh {} \; 1>>"${tmp}" 2>&1
  29. # Filter the output
  30. cat "${tmp}" | \
  31. grep -Ev "^cp: .*: could not copy extended attributes to .*: Operation not permitted$" | \
  32. grep -v "GetFileInfo: could not get info about file (-1401)" | \
  33. grep -v "ERROR: Unexpected Error. (-1401) on file: " | \
  34. grep -v "ERROR: Unexpected Error. (-5000) on file: " | \
  35. grep -v "^ *$"