Created
April 10, 2011 10:19
-
-
Save dylan-evans/912222 to your computer and use it in GitHub Desktop.
Recover from an Audacity crash by reassembling the saved data files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Recover from an Audacity crash by reassembling the saved data files | |
if [ $# != 2 ]; then | |
echo "ERROR: Not enough arguments" | |
echo "$0 [SOURCE PATH] [DESTINATION]" | |
exit 1 | |
fi | |
DATA="$1/" | |
OUT=$2 | |
if [ -e $OUT ]; then | |
# Hope the path exists | |
echo "ERROR: Output file exists ($OUT)" | |
exit 1 | |
fi | |
COUNT=1 | |
FORMAT="%sb%.5d.au\n" # I don't know if audacity sometimes uses different name formats | |
while [ 1 ]; do | |
FILE=$(printf $FORMAT $DATA $COUNT) | |
if [ -e $FILE ]; then | |
#The offsets are probably all going to be the same, but best check it | |
OFFSET=$(echo $(od -i -j4 -N4 -An < $FILE) ) # Use echo for easy trim | |
if [ $COUNT -eq 1 ]; then | |
# Write the header | |
dd ibs=$OFFSET count=1 if=$FILE of=$OUT | |
fi | |
echo "Adding $FILE (offset=$OFFSET)" | |
dd ibs=$OFFSET skip=1 conv=notrunc oflag=append if=$FILE of=$OUT | |
else | |
break | |
fi | |
let COUNT+=1 | |
done | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had problem with this script as the version of Audacity I use do not follow the same name format as the one used. Fixed in forked script (accepts any .au file).