#!/bin/bash # Base directory containing the subfolders BASE_DIR="dvoice-v1.0/audios" # Iterate through all .wav files in subdirectories find "$BASE_DIR" -type f -name "*.wav" | while read -r FILE; do # Get the directory containing the .wav file FILE_DIR=$(dirname "$FILE") # Get the name of the subfolder (relative to the base directory) SUBFOLDER_NAME=$(basename "$FILE_DIR") # Create a new folder with the same name as the subfolder in the base directory OUTPUT_DIR="dvoice-v1.0/audios_fixed/$SUBFOLDER_NAME" mkdir -p "$OUTPUT_DIR" # Extract the filename from the full path FILENAME=$(basename "$FILE") # Create the new output file path OUTPUT_FILE="$OUTPUT_DIR/$FILENAME" # Run the ffmpeg command ffmpeg -i "$FILE" "$OUTPUT_FILE" done