Hi,

I made a quick shell script that goes through the history file to gather
the sources used by a timeline session. Am I right to assume that the
history file would always have the complete info about a session, and
that I don't need to take the snapshot file into account?

This might NOT be the best shell script written on the planet, but I
would be very grateful if you could give me some feedback.
I still believe that the problem would better be solved in C, but I
don't have the time to look into it right now...
One thing I think might need to be changed is that I use a slash as a
seperator (as it is an illegal character in filenames). Can or could
the source argument become a pathname, instead of a filename?

#!/bin/bash

fatal ()
{
    echo Error: "$1"
    echo 'Aborting!'
    cleanup
    exit 1
}

usage ()
{
    fatal "Usage: $0 path/to/project"
}

[ $# -eq 1 ] || usage
cd "$PROJECT" || fatal "No such project"
[ -f history ] && [ -f info ] || fatal "Not a Non-DAW project?"
[ -f .lock ] && fatal "Project appears to be in use"

used_sources=""

while read line
do
    if grep -q '^\s*Audio_Region .* create.* :source ' <<< "${line}"
    then
        create=$(sed -n 's/.* :source "\([^"]\+\)".*$/\1/p' <<< "${line}")
        used_sources="${used_sources}${create}/"
    elif grep -q '^\s*Audio_Region .* destroy.* :source' <<< "${line}"
    then
        destroy=$(sed -n 's/.* :source "\([^"]\+\)".*$/\1/p' <<< "${line}")
        used_sources=$(sed "s/${destroy}\///" <<< "${used_sources}")
    fi
done < "history"

echo "${used_sources}" | tr "/" "\n"

exit 0

On Sun, Mar 2, 2014 at 10:22 PM, Lieven Moors <[email protected]> wrote:
>> Well, one thing I can think of that might help is having non-timeline
>> update the snapshot upon NSM save event, which I presume you're issuing
>> before all this git commiting/scripting happens? That way the snapshot
>> would be up to date at the time of the commit, and then the script could be
>> modified to allow working off of the snapshot instead of the history.
>> Another concern that just came to mind is the fact that git might be
>> obliterating the timestamp relationship between the history and snapshot
>> files in this case--which could have unexpected results.
>
>
> No, actually I'm not using NSM yet. Just shell script and git.
> So this wouldn't help me much at the moment.
>
> But thanks for trying to help me out...
>
> lieven


Reply via email to