Skip to content

Instantly share code, notes, and snippets.

@tytydraco
Last active December 30, 2022 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tytydraco/f12b796d762f91ef44efde776d521260 to your computer and use it in GitHub Desktop.
Save tytydraco/f12b796d762f91ef44efde776d521260 to your computer and use it in GitHub Desktop.
Very simple script to convert audio files to a new format
#!/usr/bin/env bash
shopt -s globstar
FROM="opus"
TO="mp3"
OUT_DIR="Converted"
for file in **/*."$FROM"
do
file_no_ext="${file%.*}"
new_file="$OUT_DIR/$file_no_ext.$TO"
new_file_pwd="$(dirname -- "$new_file")"
[[ -f "$new_file" ]] && continue
echo "$new_file"
mkdir -p "$new_file_pwd"
ffmpeg -i "$file" "$new_file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment