savetz@teamarchive0:~/AC$ cat ACBOY
#!/bin/sh
# Apple ][ Disk Image Data Extractor for Archive.org
# This is an interface between the command-line version of AppleCommander
# and Archive.org. Requires the Internet Archive Python package
# https://pypi.python.org/pypi/internetarchive
# ...and the command line version of AppleCommander renamed to ac.jar
# http://applecommander.sourceforge.net
# ...and Java (ugh)
# Buggy and imperfect, there will be further tweaking to make the output better
# By Kevin Savetz during KansasFest 2015 - savetz.com
# with help from Jason Scott - textfiles.com
# Please give generously to Internet Archive - archive.org/donate/
#clean up
rm -f DiskInfo.txt
rm -f DiskDir.txt
rm -rf DiskContents/
echo "Let's see what $1 has...."
DSK=`ia list $1 | grep -E '\.dsk$|\.dsk.$|\.do$|\.do.$|\.po$|\.nib$|\.2mg$|\.2img$|\.po.$|\.nib.$|\.2mg.$|\.2img.$' | sed 's/.$//g'`
if [ "$DSK" ]
then
for file in $DSK
do
echo "We're going to be messing with $file."
ia download $1 $file
echo ""
echo "Diskinfo..."
java -jar ac.jar -i $1/$file 2>/dev/null | sed 's/\&/\&/g' | sed 's/\</g' | sed 's/>/\>/g' | iconv -c -t UTF-8 > DiskInfo.txt
if [ -s "DiskInfo.txt" ]
then
ia metadata $1 -a "notes:Disk info for $file:
`cat DiskInfo.txt`
"
fi
rm -f DiskInfo.txt
echo "Directory..."
java -jar ac.jar -l $1/$file 2>/dev/null | grep -v -E ": null$" | sed 's/\&/\&/g' | sed 's/\</g' | sed 's/>/\>/g' | iconv -c -t UTF-8 > DiskDir.txt
if [ -s "DiskDir.txt" ]
then
HASTEXT=`cat DiskDir.txt | grep '[A-Za-z]'`
if [ "$HASTEXT" ]
then
ia metadata $1 -a "notes:Disk directory for $file:
`cat DiskDir.txt`"
fi
fi
rm -f DiskDir.txt
#now lets extract text files
echo "Text files..."
java -jar ac.jar -x $1/$file DiskContents 2>/dev/null
if [ -d "DiskContents" ]
then
cd DiskContents
# sanitize filenames
for each in *
do
OPS=`echo $each | sed 's/\//_/g' | sed 's/\\\/_/g'`
if [ ! "$each" = "$OPS" ]
then
echo "Fixing the name of $each"
mv "$each" "$OPS"
fi
done
#
file * | grep "text" | cut -f1 -d: > templist.txt
while read txtfile
do
echo " " . $txtfile
ia metadata $1 -a "notes:
Text found in $file/$txtfile:
`cat "$txtfile" | sed 's/\&/\&/g' | sed 's/\</g' | sed 's/>/\>/g' | iconv -c -t UTF-8`"
done < templist.txt
rm -f templist.txt
cd ..
#rm -rf DiskContents
fi
done
fi