Skip to content

Instantly share code, notes, and snippets.

@IOIO72
Last active April 27, 2022 17:13
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 IOIO72/2e632b0c56518f124389e406e46320cb to your computer and use it in GitHub Desktop.
Save IOIO72/2e632b0c56518f124389e406e46320cb to your computer and use it in GitHub Desktop.
WHDLoad ZIP to LHA conversion (The A500 mini)
find . -maxdepth 1 -name '*.zip' -exec mvexistsuffix {} zip lha \;
#!/bin/sh
if ([ -z $1 ] || [ -z $2 ] || [ -z $3 ])
then
echo "Usage: mvexistsuffix <filename> <suffix1> <suffix2>"
echo "Example: mvexistsuffix archive.lzh zip lha"
exit 1
fi
if [ ! -d $2 ]
then
mkdir $2
fi
if [ ! -d $3 ]
then
mkdir $3
fi
BASE=${1%.*}
FILENAME_A=${BASE}.$2
FILENAME_B=${BASE}.$3
printf "$BASE"
if ([ -f $FILENAME_A ] && [ -f $FILENAME_B ])
then
echo " -------> $2 $3"
mv $FILENAME_A $2
mv $FILENAME_B $3
else
echo ""
fi
#!/bin/sh
# $VER: ZIP2LHA v1.0.0 by TCH
command -v unzip >/dev/null 2>/dev/null || { echo >&2 "Please install unzip."; exit 1; }
command -v lha >/dev/null 2>/dev/null || { echo >&2 "Please install lha."; exit 1; }
if [ -z $1 ]
then
echo "Usage: zip2lha <zipfile>"
exit 0
fi
if [ ! -e $1 ]
then
echo "File does not exists."
exit 1
fi
FNF=${1##*/}
FN=${FNF%.zip}
DN=${FN}_tmp
printf "$FN..."
unzip $1 -d $DN >/dev/null 2>/dev/null
if [ ! -d $DN ]
then
echo "Failed to extract ZIP archive."
exit 1
fi
cd $DN
lha -a ../$FN.lha * >/dev/null 2>/dev/null
cd ..
rm -r $DN
echo "ok"
#!/bin/sh
find . -maxdepth 1 -name '*.zip' -exec zip2lha {} \;
@IOIO72
Copy link
Author

IOIO72 commented Apr 10, 2022

  1. install lha (i.e. brew install lha)
  2. set execute permission to all scripts chmod +x {script}
  3. move scripts to /usr/local/bin/
  4. change directory to WHDLoad game images. (note: the script does not traverse through the subdirectorires)
  5. if you have zip and corresponding lha archives for the same games, execute finished2folders.sh
  6. execute zip2lha-all.sh to convert all zip archives of the current folder to lha
  7. execute finished2folders.sh to move all corresponding zip and lha archives to subfolders.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment