modern_lisp-machine/misc/scripts/decompress_7z.sh

26 lines
760 B
Bash
Executable File

#!/bin/sh
# Ensure that 7z is installed
if ! command -v 7z >/dev/null 2>&1; then
echo "Error: 7z not found. Please install 7z before running this script."
exit 1
fi
# Function to create directory with Unicode compatibility and strip file extension
create_directory() {
directory_name=$(basename "$1" | sed -E 's/\.(7z|zip)$//' | iconv -t utf-8)
mkdir -p "$directory_name"
}
# Loop through each compressed file in the current folder
for compressed_file in *.7z *.zip; do
# Create a directory for the compressed file
create_directory "$compressed_file"
# If you don't want to extract immediately, comment out the following line
7z x "$compressed_file" -o"$PWD/$directory_name"
done
echo "Extraction completed successfully."