Add some status and safety checks

This commit is contained in:
2025-11-27 03:21:45 +00:00
parent 52572ef7ee
commit dba00da901
2 changed files with 25 additions and 3 deletions
+14
View File
@@ -17,7 +17,13 @@ cleanup_temp() {
fi
}
# Count total files
TOTAL_FILES=$#
CURRENT_FILE=0
for INFILE in "$@"; do
CURRENT_FILE=$((CURRENT_FILE + 1))
echo "Processing file $CURRENT_FILE of $TOTAL_FILES: $INFILE"
# Absolute path to old file
#OLDFILE=$(realpath "${INFILE}")
OUTFILE="${INFILE%.zip}-compress.zip"
@@ -70,6 +76,14 @@ for INFILE in "$@"; do
# Preserve file modification time
touch -r "$INFILE" "$OUTFILE"
# Check that OUTFILE exists and is not empty before deleting INFILE
if [ ! -s "$OUTFILE" ]; then
echo "Error: Output file is empty or does not exist. Keeping original file."
cleanup_temp
continue
fi
rm "$INFILE"
mv "$OUTFILE" "$INFILE"