Assists music production by grouping standalone programs into sessions. Community version of "Non Session Manager".
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
2.6KB

  1. #!/bin/sh
  2. # Copyright (C) 2008 Jonathan Moore Liles #
  3. # #
  4. # This program is free software; you can redistribute it and/or modify it #
  5. # under the terms of the GNU General Public License as published by the #
  6. # Free Software Foundation; either version 2 of the License, or (at your #
  7. # option) any later version. #
  8. # #
  9. # This program is distributed in the hope that it will be useful, but WITHOUT #
  10. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
  11. # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
  12. # more details. #
  13. # #
  14. # You should have received a copy of the GNU General Public License along #
  15. # with This program; see the file COPYING. If not,write to the Free Software #
  16. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #
  17. ## import-external-sources
  18. #
  19. # June 2008, Jonathan Moore Liles
  20. #
  21. # Simple script to scan a compacted Non-DAW project and copy external
  22. # sources into the project directory.
  23. #
  24. # USAGE:
  25. #
  26. # $ import-external-sources ~/audio/'The Best Song Ever'
  27. DRY_RUN=no
  28. ONLY_COMPACTED=no
  29. fatal ()
  30. {
  31. echo Error: "$1"
  32. echo 'Aborting!'
  33. cleanup
  34. exit 1
  35. }
  36. cleanup ()
  37. {
  38. rm -f "${TEMP}/external-sources"
  39. }
  40. import_sources ()
  41. {
  42. local FILE
  43. while read FILE
  44. do
  45. if [ $DRY_RUN = yes ]
  46. then
  47. echo "Would import: ${FILE}"
  48. else
  49. echo "Importing source \"${FILE}\"..."
  50. cp "${FILE}" sources
  51. [ -f "${FILE}.peak" ] && cp "${FILE}.peak" sources
  52. ( echo "%s':source \"${FILE}\"':source \"${FILE##*/}\"'"; echo -e "\nwq" ) |
  53. ed -s "history"
  54. fi
  55. done
  56. }
  57. [ $# -gt 0 ] || fatal "Usage: $0 [--dry-run] path/to/project"
  58. if [ "$1" = --dry-run ]
  59. then
  60. DRY_RUN=yes
  61. shift 1
  62. fi
  63. PROJECT="$1"
  64. cd "$PROJECT" || fatal "No such project"
  65. [ -f history ] && [ -f info ] || fatal "Not a Non-DAW project?"
  66. [ -f .lock ] && fatal "Project appears to be in use"
  67. if [ $ONLY_COMPACTED = yes ]
  68. then
  69. grep -v '\(^\{\|\}$\)\|create' history && fatal "Not a compacted project"
  70. fi
  71. echo "Scanning \"${PROJECT}\"..."
  72. sed -n 's/^\s*Audio_Region .* create :source "\([^"]\+\)".*$/\1/; /^\//p' history | sort | uniq > "${TEMP}/external-sources"
  73. import_sources < "${TEMP}/external-sources"
  74. cleanup
  75. echo "Done."