Created
May 3, 2020 07:50
-
-
Save jamespo/8507608997fd3cd13ba0d86dd8c054d2 to your computer and use it in GitHub Desktop.
zip2lha.sh - convert zip files (for WHDLOAD) into lha for retropie / amiberry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# zip2lha.sh - convert zip files (for WHDLOAD) into lha for retropie / amiberry | |
# USAGE: zip2lha.sh zipfilename.zip | |
# or to do whole directory: find . -name '*.zip -exec zip2lha.sh {} \; | |
# set TMPDIR & DESTDIR in script | |
# REQUIREMENTS: unzip & jlha-utils (NOT lha package) on raspbian | |
# BE CAREFUL! This script removes contents of TMPDIR after each conversion | |
FN=$1 | |
LHAFN=$(echo $FN |sed -e 's/.zip/.lha/') | |
TMPDIR=/data/tmp | |
DESTDIR=/data/roms/amiga/Amiga1 | |
echo "Extracting $FN to $LHAFN" | |
unzip -d $TMPDIR "$FN" > /dev/null | |
cd $TMPDIR | |
jlha -ao5 "$LHAFN" * > /dev/null | |
mv "$LHAFN" $DESTDIR | |
rm -rf * |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! Thanks for the script. HOWEVER, the rm command at the end is very dangerous. If the TMPDIR doesn't exist, the cd command will fail, and rm will delete everything in the directory the script is invoked from! (Imagine running it from $HOME …) Besides, /data/tmp is no standard directory in any Linux system that I know of, including Retropie. So, in a standard Linux system or Retropie, your script will delete everything in the dir that is run from.
Thus, you should catch a missing TMPDIR and stop the script with an error message, or at least run the rm explicitly on the TMPDIR from outside of it (e.g. end the script with
cd -; rm -rf * $TMPDIR/*
). Cheers.edit: Here's a quick dirty rewrite that creates the TMPDIR (here "lhatmp" in the current dir) and deletes it afterwards. (Hint for onlookers: Make DESTDIR=.. to place the lha in the dir the script is invoked from.)