dotfiles/fish/functions/audio_to_ogg.fish
Irrlicht a61c6756fc [fish] Useful Fish functions
- audio_to_ogg: go recursively through directories and convert all wma
  and m4a file to Ogg Vorbis
- ffmpeg and ffprobe alias to remove the banner (-hide_banner)
2025-06-10 18:23:32 +02:00

23 lines
864 B
Fish

function audio_to_ogg -d "Convert m4a,wma files to Ogg Vorbis"
argparse 'h/help' 'd/delete' -- $argv
if set -q _flag_help
echo "usage: audio_to_ogg [-h | --help] [-d | --delete]"
echo "Convert all m4a, wma files to Ogg Vorbis using ffmpeg"
echo "-d,--delete Delete original file after conversion"
echo "-h,--help display this help message"
return 0
end
for i in **.wma **.m4a
set audio_path $(path resolve $i)
set dir_path $(path dirname $audio_path)
set file_name $(path basename -E $audio_path)
set out_path "$dir_path/$file_name.ogg"
echo Converting $audio_path to $out_path
ffmpeg -i $audio_path -map 0:a:0 -c:a libvorbis -qscale:a 8 $out_path
if set -q _flag_delete && test $status -eq 0
rm $audio_path
end
end
end