Skip to content

Instantly share code, notes, and snippets.

@tamsky
Forked from javierwilson/audacity_rescue2.sh
Created November 10, 2023 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamsky/7499ae51a5df4556405b00cd387dfbf0 to your computer and use it in GitHub Desktop.
Save tamsky/7499ae51a5df4556405b00cd387dfbf0 to your computer and use it in GitHub Desktop.
recover audacity 2.0 crash data
#!/bin/bash
#Recover from an Audacity 2.0 crash by reassembling the saved data files
#Based on https://gist.github.com/912222
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
find $DATA -type f -name "*au" | sort > /tmp/audacity_rescue.txt
while IFS= read -r FILE; do
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 < "/tmp/audacity_rescue.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment