I want to merge splited audio files in sub folder with Sox
. I have this basic script
#!/bin/bash
# Example: sox_merge_subfolder.sh input_dir/ output_dir/
# Soure directory with subfolder that contains splitted mp3
input_dir=$1
# Set the directory you want for the merged mp3s
output_dir=$2
# make sure the output directory exists (create it if not)
mkdir -p "$output_dir"
find "$input_dir" -type d -print0 | while read -d $'\0' file
do
echo "Processing..."
cd "$file"
output_file="$output_dir/${PWD##*/} - Track only.mp3"
echo " Output: $output_file"
sox --show-progress *.mp3 "$output_file"
done
It is working but I would like to switch to a command that use only folders that contains mp3
. To avoid error like sox FAIL formats: can't open input file '*.mp3': No such file or directory
I have this command that work find . -maxdepth 2 -name "*.mp3" -exec dirname {} \; | uniq
. But the path are relative and I fail to include it into my existing script.