Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.