I've been having some trouble with XZ files when modified through KDE's ark program. So I decided to convert them all to GZIP files. To do that one at a time, by hand, would take forever. Hello shell scripting.
#!/bin/bash
#DEBUG="echo";
CWD=$(pwd);
XZFILE="$1";
if [ -z "$XZFILE" ]; then
echo "No file given!";
exit 1;
fi
XZFILE=$(realpath "$XZFILE");
TARGETDIR=${XZFILE%/*};
GZFILE=${XZFILE##*/};
GZFILE="${GZFILE%xz}gz";
NEWDIR="/tmp/xz2gz.$$";
echo $XZFILE;
$DEBUG mkdir "$NEWDIR";
$DEBUG tar -Jxvf "$XZFILE" -C "$NEWDIR";
$DEBUG pushd "$NEWDIR";
$DEBUG tar -czf "$GZFILE" *;
$DEBUG mv "$GZFILE" "$TARGETDIR";
$DEBUG popd;
$DEBUG rm -Rf "$NEWDIR";
No comments:
Post a Comment
Comments welcome, but they are expected to be civil.
Please don't bother spamming me. I'm only going to delete it.