Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@keisei1092
Last active June 30, 2018 14:57
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 keisei1092/31a8fd3677348d6123b049661c5eb59c to your computer and use it in GitHub Desktop.
Save keisei1092/31a8fd3677348d6123b049661c5eb59c to your computer and use it in GitHub Desktop.
指定したディレクトリにあるwavファイルを320kbpsのmp3ファイルに変換する

wav2mp3

指定したディレクトリにあるwavファイルを320kbpsのmp3ファイルに変換する
変換されたwavファイルは自動で削除します

Prerequisites

  • ffmpeg がインストールされていること
    • Homebrew がインストールされているmacOSなら brew install ffmpeg で入る
  • trash がインストールされていること
    • brew install trash するか ここ とか見て手動で入れてください

Code

次のコードを /usr/local/bin/wav2mp3 とかに置く

#!/bin/sh

find $1 -name "*.wav" | while read line; do
	< /dev/null ffmpeg -i "${line}" -ab 320k "${line%.*}.mp3";
	trash "${line}";
done

Usage

ターミナルを開き、変換したいファイル群があるディレクトリに行って次を入力します

wav2mp3 .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment