2015-10-30 12:34:48 +00:00
|
|
|
#! /bin/bash
|
2016-10-25 17:42:29 +00:00
|
|
|
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
|
2015-10-30 12:02:02 +00:00
|
|
|
|
2018-06-25 04:48:42 +00:00
|
|
|
# shk2image - Extract .shk files to Apple II disk images
|
|
|
|
#
|
|
|
|
# To the extent possible under law, T. Joseph Carter and Ivan Drucker have
|
|
|
|
# waived all copyright and related or neighboring rights to the a2cloud
|
|
|
|
# scripts themselves. Software used or installed by these scripts is subject
|
|
|
|
# to other licenses. This work is published from the United States.
|
|
|
|
|
2015-10-30 12:02:02 +00:00
|
|
|
origDir="$PWD"
|
|
|
|
[[ ! -n $1 || ! -n $2 ]] && { echo "Usage: shk2image archiveFileName imageFileName [PRODOS.DIR.NAME]"; exit 1; };
|
|
|
|
imageFileName="$2";
|
|
|
|
prodosDir="$3";
|
|
|
|
[[ ! -f "$1" ]] && { echo "Archive file '$1' was not found."; exit 1; };
|
|
|
|
[[ ! -f "$imageFileName" ]] && mkpo "$imageFileName";
|
|
|
|
[[ -n $prodosDir ]] && dirName="$prodosDir/" || dirName=;
|
|
|
|
IFS="";
|
|
|
|
[[ ${1:0:1} == "/" ]] && archiveFile="$1" || archiveFile="$origDir/$1"
|
|
|
|
mkdir -p /tmp/shk2image_temp
|
|
|
|
cd /tmp/shk2image_temp
|
|
|
|
shkFiles=$(nulib2 -xse "$archiveFile" | tr "\r" "~" | cut -d "~" -f 2 | cut -c 18-);
|
|
|
|
cd "$origDir"
|
|
|
|
while read thisFile; do
|
2016-10-25 17:42:29 +00:00
|
|
|
fileName=${thisFile%%#*};
|
|
|
|
fileType=${thisFile##*#};
|
|
|
|
echo "extracting $fileName...";
|
|
|
|
acmd -d "$imageFileName" $dirName$fileName &>/dev/null;
|
|
|
|
acmd -p "$imageFileName" $dirName$fileName \$${fileType:0:2} \$${fileType:2:4} < /tmp/shk2image_temp/"$thisFile"
|
|
|
|
rm /tmp/shk2image_temp/"$thisFile"
|
2015-10-30 12:02:02 +00:00
|
|
|
done <<< $shkFiles
|
|
|
|
rm -r /tmp/shk2image_temp
|