Rename rezip to .rezip

This commit is contained in:
Attila Body 2024-09-17 14:44:23 +02:00
parent 048858c23b
commit 775b01c482
No known key found for this signature in database
GPG key ID: 3D2FC6085E166F70
5 changed files with 6 additions and 4 deletions

44
.rezip/rezip.sh Executable file
View file

@ -0,0 +1,44 @@
#!/bin/sh
#set -x
#usage rezip.sh [-#] [filename]
unset compression
while [ $# != 0 ] ; do
case $1 in
-*)
compression="$1"
;;
*)
inputfile="$1"
esac
shift
done
if [ -z "$compression" ]; then compression=-0; fi
if [ -z "$inputfile" ]; then
zipfile=$(mktemp -t rezip.zip.XXXXXXXX)
cat >"$zipfile"
else
zipfile=$(realpath "$inputfile")
fi
tmpdir=$(mktemp -d -t rezip.tmd.XXXXXXXX)
files=$(unzip -Z -1 "$zipfile")
unzip -qq -d "$tmpdir" "$zipfile"
cd "$tmpdir"
tmpfile=$(mktemp -u -t rezip.tmp.XXXXXXXX)
unzip -Z -1 "$curdir/$zipfile"| zip -qq -@ "$compression" "$tmpfile"
if [ -z "$inputfile" ] ; then
rm "$zipfile"
cat "$tmpfile"
rm "$tmpfile"
else
mv "$tmpfile" "$zipfile"
fi
rm -rf "$tmpdir"