#!/bin/bash # Date: 02/13/2023 # Author: Anthony Correa # I used this script to batch unarchive .7z files. # It will create a folder based on the 7z file name # It will automatically skip if there is a folder already in the output directory # Usage: $ ./convert_7z.sh # output_directory is the directory where the unarchived folders will go output_directory=./out mkdir -p "$output_directory" for FILE in "$@"; do ##echo "$fi" echo "========================================================================================" echo "$FILE" filename=$(basename -- "$FILE") outname="${filename%.*}" outpath="$output_directory/$outname" ##touch "./out/${fi%%.*}.new" if [ ! -d "$outpath" ]; then echo "$outpath" 7z x "$FILE" -aos -bb1 -o"$outpath" else echo "$outpath exists... skipping" fi done echo "========================================================================================" echo "Done unarchving" # at one point I wanted to tar the results to make it easier to transfer all the contents # but i changed my mind, so i commented it out. this is here in case i change my mind again. #echo "now tarring" #tar -cvf out.tar "$output_directory" echo "Done!"