#!/bin/bash

# Check if a folder name is provided as an input parameter
if [[ $# -eq 0 ]]; then
  echo "Usage: $0 <folder-name>"
  exit 1
fi

FN=$1

SCRIPT_DIR="$(dirname "$0")"
# Change to the script directory
cd "$SCRIPT_DIR"

# Extract ffmpeg.zip to the specified folder
echo "Unzipping files to ${FN}..."
unzip -q ffmpeg.zip -d "${FN}"

# Remove the quarantine attribute from all extracted files
echo "Setting permissions..."
chmod -R u+wrx "${FN}"

echo "Removing quarantine flag..."
xattr -d -r com.apple.quarantine "${FN}"

echo "ffmpeg has been installed to ${FN}."