diff --git a/tetras_extraction/script/extract_all_media_from_folder.sh b/tetras_extraction/script/extract_all_media_from_folder.sh new file mode 100755 index 0000000000000000000000000000000000000000..75275f2ee5810c73094ff3abf7025ad4d3a911ef --- /dev/null +++ b/tetras_extraction/script/extract_all_media_from_folder.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +# Check if the input and output folders are provided as arguments +if [ $# -lt 2 ]; then + echo "Usage: $0 <input_folder> <output_folder>" + exit 1 +fi + +# Get the input and output folder paths +input_folder="$1" +output_folder="$2" + +# Ensure the input folder exists +if [ ! -d "$input_folder" ]; then + echo "Error: Input folder '$input_folder' does not exist." + exit 1 +fi + +# Create the output folder if it doesn't exist +mkdir -p "$output_folder" + +# Loop through all files in the input folder +for file in "$input_folder"/*; do + # Skip if no files are found + if [ ! -e "$file" ]; then + echo "No files found in the input folder." + exit 0 + fi + + # Check if the file is an SWF file + if [[ "$file" == *.swf ]]; then + # Get the base name without extension + base_name=$(basename "$file" .swf) + + # Create a subfolder for the extracted files + subfolder="${output_folder}/${base_name}" + mkdir -p "$subfolder" + + # Extract assets using swfextract into the subfolder + echo "Processing SWF file: $file" + swfextract --outputformat "${subfolder}/${base_name}_%02d.%s" -a 1- "$file" + else + # Copy other files directly to the output folder + echo "Copying non-SWF file: $file" + cp "$file" "$output_folder/" + fi +done + +echo "All files processed! SWF files are extracted and others are copied to '$output_folder'."