Skip to content

Instantly share code, notes, and snippets.

@DrummerHead
Created July 6, 2016 17:33
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 DrummerHead/eabe79469ecc44914fbab302c488b186 to your computer and use it in GitHub Desktop.
Save DrummerHead/eabe79469ecc44914fbab302c488b186 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'shellwords'
wavs = Dir.glob("**/*.wav", File::FNM_CASEFOLD)
mp3s = Dir.glob("**/*.mp3", File::FNM_CASEFOLD)
puts "\n\n=================\n\n"
puts wavs
puts "\n\n=================\n\n"
p wavs
puts "\n\n=================\n\n"
def wav_to_mp3 paths
paths.each do |filepath|
name = (/^(.*?)\./.match(filepath) ? /^(.*?)\./.match(filepath)[1] : nil)
puts %x[ffmpeg -i #{Shellwords.escape filepath} -vn -ar 44100 -ac 2 -ab 192k -f mp3 #{Shellwords.escape name}.mp3]
puts "\n\n-----------\n\n"
end
end
def delete_files paths
paths.each do |filepath|
puts %x[rm #{Shellwords.escape filepath}]
end
end
wav_to_mp3 wavs
# delete_files wavs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment