Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ShrinkIt to disk image on Mac/Linux command line

108 views
Skip to first unread message

Ivan X

unread,
Aug 10, 2013, 3:48:42 PM8/10/13
to
ADTPro provides a command-line version of AppleCommander, which is pretty handy for getting stuff in and out of Apple II disk images (and many formats are supported, and automatically detected).

I've written a couple of functions for Bash which allow you to access AppleCommander easily (with the command "ac"), and also extract all the files in a ShrinkIt archive directly into a ProDOS disk image file ("shk2image").

Also, when writing a file into a disk image with AC's -p argument, you can specify the file type by two-digit hex rather than the three-letter name AppleCommander seems to normally require (e.g. 04 instead of TXT).

It should work on both OS X and Linux (or at least Debian-flavored Linuxes), with Java installed. Put these functions in ~/.bashrc (Linux) or ~/.bash_profile (Mac), or /etc/profile (either, and will work for all users). On a Mac, the ADTPro folder needs to be in /Applications. On Linux, the ADTPro folder (or a symlink to it) needs to be called "adtpro" and in /usr/local.

When using shk2image, if the disk image name you provide doesn't exist, it will be created (140K if the name ends in ".dsk", 800K otherwise). Any file in the disk image with the same name as the one you're extracting will be overwritten. You can also provide an optional ProDOS directory name to install into, and it will be created if necessary. Do not put a leading or trailing slash in the directory name.

Hope a few of you find these useful. I'll also be including them in an update to A2CLOUD.


ac ()
{
[[ -f /usr/local/adtpro/adtpro.sh ]] && acPath="/usr/local/adtpro" || acPath=$(ls -1d /Applications/ADTPro* | head -1);
if [[ $1 == "-p" && ${#4} == "2" ]]; then
{
local P_00="UNK";
local P_01="BAD";
local P_02="PCD";
local P_03="PTX";
local P_04="TXT";
local P_05="PDA";
local P_06="BIN";
local P_07="FNT";
local P_08="FOT";
local P_09="BA3";
local P_0a="DA3";
local P_0b="WPF";
local P_0c="SOS";
local P_0f="DIR";
local P_10="RPD";
local P_11="RPI";
local P_12="AFD";
local P_13="AFM";
local P_14="AFR";
local P_15="SCL";
local P_16="PFS";
local P_19="ADB";
local P_1a="AWP";
local P_1b="ASP";
local P_20="TDM";
local P_21="IPS";
local P_22="UPV";
local P_29="3SD";
local P_2a="8SC";
local P_2b="8OB";
local P_2c="8IC";
local P_2d="8LD";
local P_2e="P8C";
local P_41="OCR";
local P_42="FTD";
local P_50="GWP";
local P_51="GSS";
local P_52="GDB";
local P_53="DRW";
local P_54="GDP";
local P_55="HMD";
local P_56="EDU";
local P_57="STN";
local P_58="HLP";
local P_59="COM";
local P_5a="CFG";
local P_5b="ANM";
local P_5c="MUM";
local P_5d="ENT";
local P_5e="DVU";
local P_60="PRE";
local P_6b="BIO";
local P_6d="DVR";
local P_6e="PRE";
local P_6f="HDV";
local P_80="GEZ";
local P_81="GE1";
local P_82="GEO";
local P_83="GE3";
local P_84="GE4";
local P_85="GE5";
local P_86="GE6";
local P_87="GE7";
local P_88="GE8";
local P_89="GE9";
local P_8a="GEA";
local P_8b="GEB";
local P_8c="GEC";
local P_8d="GED";
local P_8e="GEE";
local P_8f="GEF";
local P_a0="WP_";
local P_ab="GSB";
local P_ac="TDF";
local P_ad="BDF";
local P_b0="SRC";
local P_b1="OBJ";
local P_b2="LIB";
local P_b3="S16";
local P_b4="RTL";
local P_b5="EXE";
local P_b6="STR";
local P_b7="TSF";
local P_b8="NDA";
local P_b9="CDA";
local P_ba="TOL";
local P_bb="DRV";
local P_bc="LDF";
local P_bd="FST";
local P_bf="DOC";
local P_c0="PNT";
local P_c1="PIC";
local P_c2="ANI";
local P_c3="PAL";
local P_c5="OOG";
local P_c6="SCR";
local P_c7="CDV";
local P_c8="FON";
local P_c9="FND";
local P_ca="ICN";
local P_d5="MUS";
local P_d6="INS";
local P_d7="MDI";
local P_d8="SND";
local P_db="DBM";
local P_e0="SHK";
local P_e2="DTS";
local P_ee="R16";
local P_ef="PAS";
local P_f0="CMD";
local P_f9="P16";
local P_fa="INT";
local P_fb="IVR";
local P_fc="BAS";
local P_fd="VAR";
local P_fe="REL";
local P_ff="SYS";
shift;
local ft;
local fc="P_$3";
[[ -n ${!fc} ]] && ft=${!fc} || ft="\$$3";
java -jar "$acPath"/lib/AppleCommander/AppleCommander*.jar -p "$1" "$2" $ft "$4"
};
else
java -jar "$acPath"/lib/AppleCommander/AppleCommander*.jar $@;
fi
}


shk2image ()
{
[[ ! $1 || ! $2 ]] && { echo "Usage: shk2image archiveFileName imageFileName [prodosDirectory]"; return 1; };
[[ ! -f "$2" ]] && {
[[ ${2##*.} == ".dsk" ]] && ac -pro140 "$2" "UNTITLED" || ac -pro800 "$2" "UNTITLED"
};
[[ -n $3 ]] && dirName="$3/" || dirName=;
IFS_orig="$IFS";
IFS='';
shkFiles=$(nulib2 -xse "$1" | tr '\r' '~' | cut -d '~' -f 2 | cut -c 18-);
while read thisFile; do
{
fileName=${thisFile%%#*};
fileType=${thisFile##*#};
echo "extracting $fileName...";
ac -d "$2" $dirName$fileName &>/dev/null;
ac -p "$2" $dirName$fileName ${fileType:0:2} '$'${fileType:2:4} <<< $thisFile
};
done <<< $shkFiles;
IFS="$IFS_orig"
}
0 new messages