Last active
September 13, 2018 17:34
-
-
Save superzazu/b76d37c974058fe70c9a433f3e669dc0 to your computer and use it in GitHub Desktop.
Create a .tar.xz file from a .rsn file (SNES music file)
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
#!/usr/bin/env bash | |
# create .tar.xz out of a .rsn file | |
set -e | |
if [[ $# -ne 2 ]]; then | |
echo "usage: rsntotarxz input.rsn output.tar.xz" >&2 | |
exit 1 | |
fi | |
infile="$1" | |
outfile="$2" | |
temp_folder="/tmp/rsntotarxz" | |
if ! [ -x "$(command -v unrar)" ]; then | |
echo "error: unrar is not installed" >&2 | |
exit 1 | |
fi | |
if ! [ -x "$(command -v tar)" ]; then | |
echo "error: tar is not installed" >&2 | |
exit 1 | |
fi | |
if ! [ -x "$(command -v xz)" ]; then | |
echo "error: xz is not installed" >&2 | |
exit 1 | |
fi | |
if [ -d "$temp_folder" ]; then | |
echo "error: temporary folder '$temp_folder' already exists, exiting" >&2 | |
exit 1 | |
fi | |
if [ -f "$outfile" ]; then | |
echo "error: output file '$outfile' already exists, exiting" >&2 | |
exit 1 | |
fi | |
mkdir $temp_folder | |
unrar x $infile $temp_folder | |
# env GZIP=-9 tar cvzf $outfile -C $temp_folder . | |
env XZ_OPT=-9e tar cJf $outfile -C $temp_folder . | |
rm -rf $temp_folder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment