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