File size: 898 Bytes
1f9dab2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
#!/bin/zsh
# Function to convert ogg to wav
convert_ogg_to_wav() {
local input_file="$1"
local output_file="${input_file:r}.wav"
ffmpeg -i "$input_file" "$output_file"
echo "Converted: $input_file -> $output_file"
}
# Set the target directory
if [[ $# -eq 0 ]]; then
target_dir="."
else
target_dir="$1"
fi
# Check if the target directory exists
if [[ ! -d "$target_dir" ]]; then
echo "Error: Directory '$target_dir' does not exist."
exit 1
fi
# Find all .ogg files in the target directory and its subdirectories
ogg_files=($(find "$target_dir" -type f -name "*.ogg"))
# Check if any .ogg files were found
if [[ ${#ogg_files[@]} -eq 0 ]]; then
echo "No .ogg files found in '$target_dir' or its subdirectories."
exit 0
fi
# Convert each .ogg file to .wav
for file in "${ogg_files[@]}"; do
convert_ogg_to_wav "$file"
done
echo "Conversion complete."
|