#!/bin/bash

# Source directory containing WAV files
SOURCE_DIR="/home/christian/audio/reference-audio-wav"
# Target directory to save trimmed WAV files
TARGET_DIR="/home/christian/audio/reference-audio-wav-short"

# Create target directory if it does not exist
mkdir -p "$TARGET_DIR"

# Loop over all WAV files in the source directory
for file in "$SOURCE_DIR"/*.wav; do
  # Extract the filename without the path
  filename=$(basename "$file")
  
  # Use ffmpeg to trim the file to 10 seconds and save it in the target directory
  ffmpeg -i "$file" -t 10 "$TARGET_DIR/$filename"
done